The Old Testament often represents metaphors, symbols or characters which points to Jesus Christ and God’s plan of Salvation, these are called ‘Type of Christ”. “You intended to harm me, but God intended it for good to accomplish what is now being done, the saving of many lives.” (Gen 50:20) Joseph in the Bible as the Type of Christ:
(Also check out, How to overcome temptation and Temptation of Jesus Christ in the Wilderness)