One of the famous questions that is asked regarding the Exodus from Egypt and the whole issue of the slavery of the Jews in Egypt is that, indeed G-d had actually told Abraham that his children would be slaves in a foreign land, he predicted the exile, He said the Jews would be enslaved. If so, the commentaries ask, then the Egyptians should not get punished, because they were fulfilling G-d’s decree. The Egyptians were G-d’s messengers or agents in fulfilling the decree of exile.
Nachmanides’ offers a number of approaches. First, he says, G-d decreed that the Jews be enslaved; He did not decree murder, rape, and torture. Slavery is one thing, but genocide is something totally different. So the Egyptians went overboard and therefore they deserved punishment for the evils that they perpetrated beyond G-d’s decree of slavery.
The second answer he suggests is related to the intention of the Egyptians. For example, if an authentic prophet, like Jeremiah, Ezekiel or Isaiah would give a commandment to someone to do something which is normally forbidden, like beating someone or even killing, it would be difficult and terrible but we would have to obey. Now, supposing the prophet said that he wanted you to beat up a person whom you hated, although legally you would be obligated to obey, but you would only be meritorious in G-d’s eyes if you did the act for the right reasons. Nachmanides says that if you beat the person because you hated him, then he says, you have committed an act of assault and battery. The court cannot punish you because it was commanded by a prophet, but in the eyes of heaven, you are a violent criminal. The Egyptians probably did not even know that the slavery was a Divine decree, but even if they know the fact remains they probably did not enslave the Jew reluctantly, with tears in their eyes, in order to fulfill the words of G-d to Abraham. They enslaved the Jews for their own selfish reasons – economic, political, and social – and therefore they deserved punishment.
Maimonides approaches the issue from the perspective of free will. G-d’s decree to Abraham that his children would be slaves was based upon G-d’s knowledge that the majority of the Egyptians would indeed make an immoral choice and choose to enslave the Jews. But, G-d did not force any individual Egyptian to enslave the Jews. He didn’t call someone by name and force him to oppress innocent people. Rather, G-d placed the Jews and Egyptians in circumstances that would give the Egyptians the opportunity to oppress the Jews. G-d knew that the Egyptians would seize the opportunity for their own benefit and enrichment and enslave the Jews. So He could safely predict and tell Abraham, “your children will be slaves” without forcing the Egyptians to enslave the Jews. Every individual Egyptian still had his or her free will. Each Egyptian had the ability to say, “I will not do this, it is immoral, and it is wrong.” When they happily consented to be part of the enslavement, torture and genocide of the Jewish people, then indeed they could be punished because they are doing it as a result of their own free will.