The Israelites were slaves in Egypt. They prayed for freedom and God heard their prayers. He appeared to Moses and appointed him to deliver the people.
Then the LORD said, “I have surely seen the affliction of my people who are in Egypt and have heard their cry because of their taskmasters. I know their sufferings, and I have come down to deliver them out of the hand of the Egyptians and to bring them up out of that land to a good and broad land, a land flowing with milk and honey, to the place of the Canaanites, the Hittites, the Amorites, the Perizzites, the Hivites, and the Jebusites. And now, behold, the cry of the people of Israel has come to me, and I have also seen the oppression with which the Egyptians oppress them.Come, I will send you to Pharaoh that you may bring my people, the children of Israel, out of Egypt.” (Exodus 13:7-10)
Exodus 7:1-12:40 describes the ten plagues God had to send on the Egyptians before they would let the Israelites leave to go to the land God had promised them. Yet even after all of this suffering Pharaoh changed his mind about freeing the Israelites and tried to bring them back into slavery. Exodus 14:5-31 tells how God opened the Red Sea to allow the Israelites to escape and then allowed the sea to return to drown Pharaoh and his army. Israel was finally free to go to its own land and Egypt was in ruins with its ruler dead.
But God’s judgments had another result.
“Behold, about this time tomorrow I will cause very heavy hail to fall, such as never has been in Egypt from the day it was founded until now.Now therefore send, get your livestock and all that you have in the field into safe shelter, for every man and beast that is in the field and is not brought home will die when the hail falls on them.” Then whoever feared the word of the Lord among the servants of Pharaoh hurried his slaves and his livestock into the houses, but whoever did not pay attention to the word of the Lord left his slaves and his livestock in the field.
Not all of the Egyptians were as hard hearted as Pharaoh. Some of them feared God and took steps to protect themselves. When the Isrealites left Egypt they left behind a group of people who believed in the true God.