Imam through his theological works explains the matter as following:
All moral and behavioral corruptions ensue from the absence of faith in one’s heart i.e. whatever the intellect and reason have comprehended through rational proofs or the reports of the prophets fails to enter the heart, and the heart is unaware of their truth.
One of the doctrines which every ‘arif, Hakim, mutakallim, as well as the laity and the legists, affirm and regard as indubitable is that whatever has come into existence as the result of the stroke of the Pen of the absolutely Wise Creator, from the viewpoint of being and perfection to the apportioning of the means of sustenance among creatures and the ordination of their terms of life---everything demonstrates the utmost beauty of design and the utmost perfection of a system which is in complete accordance with the sumum bonum of the creatures and the most complete and perfect system imaginable.
However, each one of them describes this graciousness of God and His absolute wisdom in his own specific language and in accordance with the terminology of his discipline. The ‘arif says, “It is the shadow of the Absolute Beauty.”
The Hakim says, “The system of the real world is in accordance with a scientific scheme free from any defect and evil; that which is presumed to be evil in particular instances is nothing but a means for the creatures to acquire their deserved degree of perfection.” The mutakallim and the legist believe that God’s Acts are based upon wisdom and the general good, and man’s limited intellect is incapable of comprehending the higher good intrinsic in Divine ordainments.
All subscribe to this idea and everyone sets forth an argument to prove it according to his own knowledge and intelligence, Imam further explained.
But since they do not go beyond words and have not entered the heart, voices of protest and objection can still be heard, and yet the same man, not enjoying the bounty of faith, counters his own words and confutes his own arguments. Moral vices, too, are rooted in this weakness of faith.
Read more:
This world is the abode of duty and the farm of the Hereafter, Imam Khomeini explained