“As for you, you meant evil against me, but God meant it for good in order to bring about this present result” (Genesis 50:20)
And we know that in all things God works for the good of those who love him, who have been called according to his purpose. (Romans 8:28)