The scriptures are clear in their teachings about controlling the powers of heaven. The seminal scripture is found in DC 121, the powers of heaven cannot be controlled nor handled only upon the principles of righteousness. That they may be conferred upon us, it is true; but when we undertake to cover our sins, or to gratify our pride…the heavens withdraw themselves; the Spirit of the Lord is grieved ; and when it is withdrawn, Amen to the priesthood or the authority of that man (DC 121:36-7). So righteousness is the prerequisite for performing miracles because a corrupt tree cannot bring forth good fruit (Matt 7:18).
In DC 46, we learn of the gifts of the Spirit. Two of those gifts are faith to heal and the working of miracles (DC 46:21). Seldom do we carefully read the words of the Lord before and after this list of gifts. He counsels us to follow the Spirit…in all holiness of heart, walking uprightly before me…And ye must practise virtue and holiness before me continually (DC 46:7,33). In other words, in order for us to exercise the gifts of the Spirit, miracles included, we must first be cleansed every whit from iniquity.
Hartman Rector Jr.
"The prophet Mormon stated very plainly what I like to call the qualification for the performance of miracles. It is recorded in 3 Nephi…’there was not any man who could do a miracle in the name of Jesus save he were cleansed every whit from his iniquity.’
“So this is the qualification: we must be cleansed every whit from our iniquity. When I first read this passage of scripture, I felt to say ’Hurray for repentance!’ for if it were not for repentance, there would be no miracles performed.” (Conference Report, Apr. 1970, p. 103)
Elder Charles A. Callis
“Isn’t this a clarion call to purity of life? The cleaner our lives, the purer our thoughts, the greater will be our power, by the prayer of faith, to heal those who are afflicted with bodily ills. It is the truth that the many mighty miracles that Jesus the Redeemer wrought was due to the fact that he lived so close to the Father, lived so perfectly the celestial laws of God, that unto him was given that superhuman power.” (Conference Report, Apr. 1924, p. 81)