מבכור פרעה עד בכור השפחה. כָּל הַפְּחוּתִים מִבְּכוֹר פַּרְעֹה וַחֲשׁוּבִים מִבְּכוֹר הַשִּׁפְחָה הָיוּ בִּכְלָל; וְלָמָּה לָקוּ בְּנֵי הַשְּׁפָחוֹת? שֶׁאַף הֵם הָיוּ מְשַׁעְבְּדִים בָּהֶם וּשְׂמֵחִים בְּצָרָתָם:
מבכור פרעה עד בכור השפחה FROM THE FIRSTBORN OF PHARAOH UNTO THE FIRSTBORN OF THE HANDMAID — All who were of less importance than the firstborn of Pharaoh and of more importance than the firstborn of the handmaid are included in this description. And why were the sons of the handmaids stricken? Because they, too, treated them (the Israelites) as slaves and rejoiced at their misery (Midrash Tanchuma, Bo 7).
In my opinion, this explanation of Rashi hints to the principle of "וְאָהַבְתָּ לְרֵעֲךָ כָּמוֹךָ" and that the maids also got the punishment of "מַכַּת בְּכוֹרוֹת" shows how important this principle is for the Torah.
[יב] … "ואהבת לרעך כמוך" – רבי עקיבא אומר זה כלל גדול בתורה. …
12) … "And you shall love your neighbor as yourself": R. Akiva says: This is an all-embracing principle in the Torah. …