There are three remedies for this sickness:
One of them is for you to say: “The learned man who, you allege, devours what is illicit, knows that such illicit things are forbidden just as well as you know that wine and pork and usury–to say nothing of backbiting, lying, and slander–are forbidden. Now you know that, yet you do such things, not because of the lack of your belief that it is disobedience, but rather because of your desire which gets the better of you. Well his desire is like yours, and it has indeed got the better of him. So his technical knowledge of subtle questions beyond this prohibition, by which he is distinguished from you, does not necessarily involve a more severe warning against this or that specific illicit action. How many a man who believes in medicine cannot abstain from fruit and cold water, even though he has been warned against them by his physician! But that does not prove that they are not injurious, or that faith in medicine is unsound. This, therefore, is the way to construe the faults of the learned.”
The second remedy is that the man in the street be told: “You ought to be believe that the learned man has acquired his learning as a provision for himself in the afterlife and supposes that his learning will save him and will be an intercessor for him. So in view of that he may be negligent in his actions because of the merit of his learning. And though it be possible that his learning will be additional evidence against him, yet he thinks it possible that it will procure him a higher rank in heaven. This may be the case for, even though he has given up good works, he can adduce his learning in his favor. But you, common man that you are, if you pattern yourself on him and give up good works without having any learning, you will perish because of your evildoing, and there will be no intercessor for you!”
The third remedy, and this is the real one, is that the true man of learning commits a sin only by way of a slip, but will in no way stubbornly persist in his sins. For true learning is that which leads to the knowledge that sin is a deadly poison and that the afterlife is better than this life. And anyone who knows that will not barter the better for something inferior. This knowledge is not the fruit of the various types of knowledge with which most men busy themselves. Hence the knowledge they acquire only makes them bolder in disobeying God Most High. True knowledge, on the other hand, increases its possessor’s reverence, fear, and hope, and this stands between him and the commission of sins, save for those slips from which, in moments of weakness, no man is free. But this is not a sign of weak faith, for the believer is tried but continually repentant, and he is far from stubborn impenitence.
Source: Deliverance from Error (al-Munqidh min al-Dalal) by Al-Ghazali (translated by R.J. Mccarthy, S.J.), pp. 79-80. Please note that the title given is of my own and not included in the actual work.