The seventh chapter of Moroni is a brief resumé of Mormon’s teachings on faith, hope, and charity. Mormon indicates here that the spirit of the law is extremely important. In fact, he says that if a person keeps a commandment but does it with the wrong spirit or for the wrong purpose, it would not be a blessing to him:
God hath said a man being evil cannot do that which is good; for if he offereth a gift, or prayeth unto God, except he shall do it with real intent it profiteth him nothing.For behold, it is not counted unto him for righteousness.
For behold, if a man being evil giveth a gift, he doeth it grudgingly; wherefore it is counted unto him the same as if he had retained the gift; wherefore he is counted evil before God.
And likewise also is it counted evil unto a man, if he shall pray and not with real intent of heart; yea, and it profiteth him nothing, for God receiveth none such.
Wherefore, a man being evil cannot do that which is good… . (Moroni 7:6-10.)
Essentially this same teaching is contained in the Doctrine and Covenants: “… he that doeth not anything until he is commanded, and receiveth a commandment with doubtful heart, and keepeth it with slothfulness, the same is damned.” (D&C 58:29.) Here again the person keeps the commandment, but he does it “with slothfulness”; therefore it is not accounted unto him for righteousness.