Genesis 50:20 But as for you, ye thought evil against me; but God meant it unto good, to bring to pass, as it is this day, to save much people alive.
This verse goes along with Romans 8:28, bad things will happen to all of us, but it is so good to know that God will take what Satan intends for evil and work it for our good. The above verse was spoken by Josepth talking to the very brothers that had sold him into slavery and led to him being in jail. But you see if that hadn't happened then him and his whole family would've died in the famine. God knows what he is doing even when it doesn't feel like it.