In The Name of Allaah, The Most Merciful, The Bestower of Mercy.
Imaam Sadi [rahimahullaah] said: Allaah has placed in man’s nature an inclination towards a woman, just like the inclination of a thirsty person towards water and that of a hungry person towards food. And even though many people do exercise patience with regards to their [desire] for food and drink, but not with regards to their [desire] for women. This is not blameworthy if it is in accordance with what is permissible, rather it is something praiseworthy.
Yusuf- at the time- was a young man and the sexual desire of a young man is much stronger. He was a bachelor, a slave of the king’s wife and was bought for a few dirhams. And a slave has no control over his affairs. He was a stranger in the land and a stranger in a strange land can fulfil his [evil] desires, which he is not able to fulfil in his own land, in the presence of his family and those who know him well [i.e. because he feels ashamed]
The wife of the King was a woman of high status and beauty; so one these two [affairs] would urge a person to agree with her request. The wife of the king was accessible [i.e. she was willing to commit the evil act of zina]. She sought after Yusuf; she desired him and was infatuated with him. Yusuf was living in her house, under her authority and would have feared being harmed for refusing to obey her. Yusuf was safe from being exposed because she sought after him and locked the doors. She also appeared in her best adornment and said to Yusuf, ‘Come on O you!’ She also threatened Yusuf with imprisonment and belittlement. She sought the assistance of the rest of the women and Yusuf sought the assistance of Allaah against them. Despite all these difficult circumstances surrounding Yusuf (alayhis-salaam), he exercised patience and preferred obedience to his Lord. He preferred the pleasure of Allaah and fear of Him. His love of Allaah made him choose imprisonment over committing zina. He said: [قَالَ رَبِّ السِّجْنُ أَحَبُّ إِلَيَّ مِمَّا يَدْعُونَنِي إِلَيْهِ ] ‘He said: ‘O my Lord! Prison is dearer to me than that to which they invite me.’ [12:33]
So What Was The End Result? Yusuf was granted honour and authority in the land. He was mentioned with good and beautiful praise. This was his reward in this worldly life and his reward in the hereafter is Paradise.
[Source: An Excerpt from ‘Al-Asbaab Wal A’maal Allatee Yudaa-afu Bihaa Ath-Thawaab’ by Imaam Sadi (rahimahullaah) pages: 55-58]