...for they are your people, and your heritage, which you brought out of Egypt, from the midst of the iron furnace.
1 Kings 8:51

The purpose of the years of oppression in Egypt was the refinement of Israel, a furnace to separate the impurities from God's chosen implement to transform the world. Ultimately, this is the purpose of every hardship. Every phase of existence is training and preparation for a future mission. Nothing is wasted in God's plan.