Zuleykha brought much trouble to Prophet Yusuf (as) during his lifetime. The Qur’an describes some of these events, such as when she attempted to seduce him (12:23-29) and after her attempts failed, she had him imprisoned (12:30-34). According to narrations, she eventually repented and Yusuf (as) married her, however what was the reason for Yusuf (as) to marry her after she had caused him much grief?

Abu Abdullah (as) said: ‘Zuleykha sought permission to (see) Yusuf (as), so it was said to her, ‘We dislike that we should proceed with you to him (as) because of what was from you to him (as)’.
She said, ‘I do not fear the one who fears Allah’.
So when she came over, he (as) said to her: ‘O Zuleykha! What is the matter that I see the colour (of your face) change?’
She said, ‘The Praise is for Allah Who Made the kings to be slaves due to their disobedience, and Made the slave to be a king due to his (as) obedience to Him.
He (as) said: ‘What invited you to me, O Zuleykha, after what had transpired from you?’
She said, ‘The beauty of your face, O Yusuf!’
So he (as) said: ‘How would it be if you were to see a Prophet called Muhammad (sawa) who would happen to be at the end of the times, more handsome than me of face, and more beautiful than me of manners, and more generous than meas of hand (in giving)’.
She said, ‘You have spoken the truth’.
He (as) said: ‘And how do you know that I have spoken the truth’.
She said, ‘Because when you mentioned him (sawa), love for him occurred in my heart’.
Therefore, Allah Mighty and Majestic Revealed unto Yusuf (as): “She is speaking the truth and that I have Loved her due to her love for Muhammad (sawa)”. And so Allah Blessed and High Commanded him (as) to marry her’.

Sanad: My father said, ‘Sa’ad Bin Abdullah narrated to us, from Ibrahim Bin Hashim, from Abdullah Bin Al Mugheira, from the one who mentioned it,

Source: `ilal al-Shara’i`, Volume 1, Chapter 48, Hadith #1 (See Image below)