Joseph was handsome in form and appearance. He was seduced by his master's wife.
Genesis 39:7 And it came to pass after these things that his master’s wife cast longing eyes on Joseph, and she said, “Lie with me.” But he refused and said to his master’s wife, “Look, my master does not know what is with me in the house, and he has committed all that he has to my hand. There is no one greater in this house than I, nor has he kept back anything from me but you, because you are his wife. How then can I do this great wickedness, and sin against God?”
The master's wife is not pleased with Joseph for being righteous & trustworthy. She invented lies to get even with Joseph for rejecting her.
Genesis 39:20 Then Joseph’s master took him and put him into the prison, a place where the king’s prisoners were confined. And he was there in the prison.
Joseph was hated for doing the right thing.
Matthew 10:22 And you will be hated by all for My name’s sake. But he who endures to the end will be saved.
Life is full of temptations. When one is given the chance to commit sin while nobody is looking and not fall into that temptation, he is a man who fear God.
Ecclesiastes 12:14 For God will bring every work into judgment, Including every secret thing, Whether good or evil.