وَلَقَدْ هَمَّتْ بِهِ ۖ وَهَمَّ بِهَا لَوْلَا أَن رَّأَىٰ بُرْهَانَ رَبِّهِ ۚ كَذَٰلِكَ لِنَصْرِفَ عَنْهُ السُّوءَ وَالْفَحْشَاءَ ۚ إِنَّهُ مِنْ عِبَادِنَا الْمُخْلَصِينَ (24)
(12:24) She advanced towards him, and he also would have advanced towards her, had he not perceived his Lord's argument. *22 This was so that We may remove indecency and immodesty from him; *23 indeed he was one of Our chosen servants.
*22) "His Lord's argument" means inspiration from Allah to rouse his conscience to the fact that it was not worthy of him to yield to the temptation by the woman. As regards the question, "What was that argument", it has been stated in the preceding verse, that is, "My Lord has shown much kindness towards me. Should I, then, misbehave like this? Such workers of iniquity never fare well. " This was the "Divine argument" that saved Prophet Joseph in the prime of youth from that great temptation. The significance of "Joseph also would have advanced towards her, had he not seen his Lord's argument" is this: "Even a Prophet like Joseph (Allah's peace be upon him) could not have been able to save himself from sin, had not Allah guided him rightly with His argument. Incidentally, this verse makes plain the nature of the "Immunity" of Prophets from sin. It does not mean that a Prophet is infallible and incapable of committing any error, offence or sin or doing wrong or making a mistake. What it means is this: though a Prophet possesses passions, emotions, and carnal desires like other human beings, and is capable of committing a sin, he is so virtuous and God-fearing that he never deliberately cherishes any evil intentions, for he is endowed with such great arguments from his Lord as do not allow the lusts of the flesh over-power the voice of his conscience. And if ever he succumbs inadvertently to any of the human weaknesses, Allah at once sends a Revelation to him to set him on the right path. For the consequences of his error do not remain confined to his own person but react on the whole mankind, for even his slightest error might mislead the world to the most horrible sins.
*23) "....so that We may remove indecency and immodesty from him" implies two things. First, "It was because of Our grace that he could perceive Our argument, and save himself from sin, for We willed to remove indecency and immodesty from Our chosen servant. " The second meaning is rather deeper: This incident took place in the life of Joseph because this was essential for his spiritual training: "It was Our will to pass him through this hard test so that he should become immune from indecency and immodesty, for he would have to apply all his powers of piety to withstand such a great temptation, and thus become really so strong as not to yield to such things in future as well" . The importance and the need of such a hard training becomes quite obvious, if we keep in view the moral conditions of the Egyptian society of that period. We can have a glimpse of this from vv. 30-32. It appears that the women in general and the "ladies" of high society in particular, enjoyed almost the same sexual freedom as is rampant today in the "civilized" West and in the Westernized East. Allah made arrangements for the special training of Prophet Joseph in the house of his master because he had to perform his Divine Mission in a perverted society, and that too as a ruler and not as a common man. It is thus obvious from the behaviour of those "ladies" of high rank, who did not feel any shame nor modesty in openly admiring the beauty of the young slave and from that of the "lady" of the house who was not ashamed of confessing openly that she did her best to tempt him and would continue to do so, that they would have done all they could to allure the young handsome ruler. Thus Allah not only made Prophet Joseph strong enough to resist such temptations in future by passing him through the hard test, but also filled the ladies with despair of gaining any "success" in this matter.