And every firstborn in the Land of Mitzrayim will die, from the firstborn of Par’oh that sits on his throne until the firstborn of the maidservant that is behind the millstone and the firstborn of all animals:
The Ohr Hachaim asks why it was imperative that Klal Yisroel only leave through the smiting of the firstborn child. Why was this the final plague that allowed them to leave?
Another question is, why did Hashem kill those firstborn children who were not Mitzrim? What did they do to deserve this? Even those who were in jail and held hostage by Mitzrayim, who presumably are not responsible for the aveiros of the Mitzrim, were killed in this plague. Why?
The Ohr Hachaim explains that when Moshe Rabbeinu first went to Par’oh, Hashem commanded him to say כֹּה אָמַר ה' בְנִי בְכֹּרִ י יִשְרָאֵל - You shall say to Par’oh, "Thus says Hashem, 'Israel is My son, My firstborn.' Klal Yisroel are called Hashem’s firstborn child.
The Zohar writes that everything that exists in the world of good has a parallel in the world of evil. Every idea that exists as a part of the holiness of Hashem’s creation, also exists as part of the evil of the world that Hashem created. The outside forces try and hold this idea and belief for themselves, and our job is to wrest it away from them and bring it to the holy side.
The idea and power of a firstborn has a similar characteristic. Just like Klal Yisroel are Hashem’s firstborn, there is a power of the firstborn that exists outside the powers of holiness. Hashem killed that off by killing the firstborn of all nations of the world that were in Mitzrayim. At that time, Hashem sanctified the firstborn of Klal Yisroel, as the possuk says כִי לִי כׇל בְכוֹר בִבְנֵי יִשְרָאֵל בָאָדָם וּבַבְהֵמָה בְיוֹם הַכֹּתִי כׇל בְכוֹר בְאֶרֶץ מִצְרַיִם הִקְדַשְׁתִי אֹּתָם לִי - For all the firstborn among the Children of Israel are mine, both man and animal. On the day that I struck all the firstborn in the land of Egypt, I sanctified them for myself.
The only power of a firstborn, after the final plague, is on the holy side, with Klal Yisroel. Even a firstborn animal had to die to remove this power completely.
Once the idea of a firstborn was totally sanctified, Klal Yisroel’s position was solidified, they were ready to leave Mitzrayim. They were now ready to be considered Hashem’s nation.