And God sent me before you to preserve for you a remnant on earth, and to keep alive for you many survivors. So it was not you who sent me here, but God. He has made me a father to Pharaoh, and lord of all his house and ruler over all the land of Egypt. Gen. 45:7-8
For the last few days I have been reading the Genesis story of Joseph to my 6 year old son and pointed out that there were many similarities (or types) in the stories between Joseph and Jesus. On our way to the bus stop we talked about the Scripture that shows where both of them were betrayed, and my son quickly responded by declaring that God also brought about a good outcome through that same betrayal. I was delighted to see that he made this connection. In both cases God intended that the evil choices of men would be the means to bring about deliverance for His people. Joseph was a type of Christ in that he suffered unjustly by his brethren and then ended up saving many of the very people who originally intended to do him harm.
I often use passages such as Genesis 50:20 as well as Acts 2 & 4 in theological debates to show God's meticulous providence that he can even ordain evil to bring about a good purpose.
"As for you, you meant evil against me, but God meant it for good, to bring it about that many people should be kept alive, as they are today." - Gen 50:20
this Jesus, delivered up according to the definite plan and foreknowledge of God, you crucified and killed by the hands of lawless men." - Acts 2:23