God turned the evil done to Joseph into a blessing. A family is spared, and a new nation is being formed. These are God's chosen people.
"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."
Genesis 50:20