It was all a part of God’s sovereign plan

"But when the time of the promise drew near which God had sworn to Abraham, the people grew and multiplied in Egypt till another king arose who did not know Joseph. This man dealt treacherously with our people, and oppressed our forefathers, making them expose their babies, so that they might not live. At this time Moses was born, and was well pleasing to God; and he was brought up in his father's house for three months. But when he was set out, Pharaoh's daughter took him away and brought him up as her own son. Acts 7:17-21

In His providence, the Lord moves people, raises up nations, and raises up leaders of nations—both good and bad. The family of Israel, that moved to Egypt to survive a famine, multiplied and became a mighty number.

A Pharaoh of Egypt arose who turned against God’s people, enslaving and abusing them. Though this was horrible, it was all a part of God’s sovereign plan—a plan, by the way, that included the birth of a deliverer named, Moses—who was a type of the Deliverer named, Jesus.

Moses, born a slave, became the adopted grandson of the evil Pharaoh to save his people, the Israelites. Jesus, the eternally begotten Son of God and King of kings from eternity past, willingly became a servant to save His people (Philippians 2:5-8).

In Acts 7:22-36, Stephen told of how Moses couldn’t deliver the Israelites by the hand of a great man. Instead, God had to strip Moses of all his greatness, remaking him a humble servant before he could be Israel’s deliverer. Similarly, in God’s providence, Jesus, the eternal Prince of Heaven, had to humble Himself and become obedient, even to death on a cross to save His people (Philippians 2:5-8).

Matthew 20:25-28 But Jesus called them to Himself and said, "You know that the rulers of the Gentiles lord it over them, and those who are great exercise authority over them. Yet it shall not be so among you; but whoever desires to become great among you, let him be your servant. And whoever desires to be first among you, let him be your slave-- just as the Son of Man did not come to be served, but to serve, and to give His life a ransom for many."