Bamidbar / Numbers 3:40
וַיֹּאמֶר יְהוָה אֶל־מֹשֶׁה פְּקֹד כָּל־בְּכֹר זָכָר לִבְנֵי יִשְׂרָאֵל מִבֶּן־חֹדֶשׁ וָמָעְלָה וְשָׂא אֵת מִסְפַּר שְׁמֹתָם׃
And the Eternal said to Moshe: "Count every firstborn male of the children of Israel from a month old and up, and take the number of their names.
Pshat פְּשָׁט
From a month old and up
Rashi: the firstborn are counted from a month, because by then there is no doubt that the child will survive. Netziv: "the number of their names" is said as in the count of all Israel, when a plague was feared and names were counted by slips. But there "head by head" was also said: each man handed in his own slip, while here there was no such fear.
How Rashi and Haamek Davar explain it
Remez רֶמֶז
A lamb for a donkey
Midrash Tanchuma: the word "count" (פָּקַד) has many meanings. There is "counting" of the firstborn, "remembering" when children are given, "care" that guards, and "appointing" to peace. The Rosh: out of love for Israel the Eternal changed the order: in the Torah a donkey is redeemed with a lamb, and He redeemed a lamb with a donkey, Israel at the price of the firstborn of Egypt.
How Midrash Tanchuma (Buber) and Rosh explain it
Drash דְּרָשׁ
Clean grain is counted
The midrash tells a parable: a king had many threshing floors, dirty and full of weeds, and he did not count them. But one floor had clean wheat, and that one the king wished to count down to the sack. So the Holy One, blessed is He, does not count the nations, but counts Israel exactly: on the floor are the righteous.
How Midrash Tanchuma (Buber) explain it
Sod סוֹד
The firstborn begins, the Levite completes
Sefat Emet: of the firstborn it says "Mine they shall be," and what is called "Mine" lasts forever. So the holiness of the firstborn did not leave. Through the sin they lost the strength to bring the task to its end, and the Eternal joined them to the work of the Levites. The firstborn begins, the Levite completes, and they need each other.
How Sefat Emet explain it