(ד) וַיֹּ֣אמֶר מֹשֶׁ֔ה כֹּ֖ה אָמַ֣ר ה' כַּחֲצֹ֣ת הַלַּ֔יְלָה אֲנִ֥י יוֹצֵ֖א בְּת֥וֹךְ מִצְרָֽיִם׃ (ה) וּמֵ֣ת כׇּל־בְּכוֹר֮ בְּאֶ֣רֶץ מִצְרַ֒יִם֒ מִבְּכ֤וֹר פַּרְעֹה֙ הַיֹּשֵׁ֣ב עַל־כִּסְא֔וֹ עַ֚ד בְּכ֣וֹר הַשִּׁפְחָ֔ה אֲשֶׁ֖ר אַחַ֣ר הָרֵחָ֑יִם וְכֹ֖ל בְּכ֥וֹר בְּהֵמָֽה׃ (ו) וְהָ֥יְתָ֛ה צְעָקָ֥ה גְדֹלָ֖ה בְּכׇל־אֶ֣רֶץ מִצְרָ֑יִם אֲשֶׁ֤ר כָּמֹ֙הוּ֙ לֹ֣א נִהְיָ֔תָה וְכָמֹ֖הוּ לֹ֥א תֹסִֽף׃ (ז) וּלְכֹ֣ל ׀ בְּנֵ֣י יִשְׂרָאֵ֗ל לֹ֤א יֶֽחֱרַץ־כֶּ֙לֶב֙ לְשֹׁנ֔וֹ לְמֵאִ֖ישׁ וְעַד־בְּהֵמָ֑ה לְמַ֙עַן֙ תֵּֽדְע֔וּן אֲשֶׁר֙ יַפְלֶ֣ה ה' בֵּ֥ין מִצְרַ֖יִם וּבֵ֥ין יִשְׂרָאֵֽל׃ (ח) וְיָרְד֣וּ כׇל־עֲבָדֶ֩יךָ֩ אֵ֨לֶּה אֵלַ֜י וְהִשְׁתַּֽחֲווּ־לִ֣י לֵאמֹ֗ר צֵ֤א אַתָּה֙ וְכׇל־הָעָ֣ם אֲשֶׁר־בְּרַגְלֶ֔יךָ וְאַחֲרֵי־כֵ֖ן אֵצֵ֑א וַיֵּצֵ֥א מֵֽעִם־פַּרְעֹ֖ה בׇּחֳרִי־אָֽף׃ {ס}
(4) Moses said, “Thus says ה': Toward midnight I will go forth among the Egyptians, (5) and every [male] first-born in the land of Egypt shall die, from the first-born of Pharaoh who sits on his throne to the first-born of the slave girl who is behind the millstones; and all the first-born of the cattle. (6) And there shall be a loud cry in all the land of Egypt, such as has never been or will ever be again; (7) but not a dog shall snarl at any of the Israelites, at human or beast—in order that you may know that ה' makes a distinction between Egypt and Israel. (8) “Then all these courtiers of yours shall come down to me and bow low to me, saying, ‘Depart, you and all the people who follow you!’ After that I will depart.” And he left Pharaoh’s presence in hot anger.

מבכור פרעה עד בכור השפחה. כָּל הַפְּחוּתִים מִבְּכוֹר פַּרְעֹה וַחֲשׁוּבִים מִבְּכוֹר הַשִּׁפְחָה הָיוּ בִּכְלָל; וְלָמָּה לָקוּ בְּנֵי הַשְּׁפָחוֹת? שֶׁאַף הֵם הָיוּ מְשַׁעְבְּדִים בָּהֶם וּשְׂמֵחִים בְּצָרָתָם:

מבכור פרעה עד בכור השפחה 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. …