"Joseph said to them, 'Do not be afraid, for am I in the place of God? But as for you, you meant evil against me; but God meant it for good, in order to bring it about as it is this day, to save many people alive." - Genesis 50:19-20
Joseph's brothers were expecting condemnation, but Joseph gave them comfort. He says, "Am I in the place of God?" In other words, "If God wants to punish you for what you've done to me, He is able to do that. I trust in Him." David recognized this same principle when he refused to exact revenge upon Saul for seeking to destroy his life. It's the principle we've spoken of again and again--that God is able to bring His good plan even out of evil intent of others.
It's not our job to seek vengeance or retribution; God is well able to take care of that department. He's the One who can repay accurately and appropriately--but He also retains the right to show mercy. I'm so glad that God didn't destroy me the first time I did something wrong to someone else. Remember that judgment is without mercy to the one who shows no mercy, but mercy triumphs over judgment.
Joseph didn't minimize or romanticize their intent. He said it plainly, but he was able to see the overruling, overarching hand of God in and through it all. He didn't have the text of Romans 8:28 but he understood its truth. Today many of us have the text, but we don't understand its truth.
God meant it for good, to save many people alive. Ultimately everything that happened to Joseph preserved the coming of Jesus. The nation of Israel was saved through his affliction. We don't always understand "why," but because we know "Who," we need not worry. God will use everything that He allows into our lives for our eternal good & His eternal glory.