Bechorot 4 - How Firstborn Lost Their Position
Since the times of Adam sacrificial service was performed by the firstborn. Jacob, who was born second, had to buy this right from Esau. This was still the practice when Jews came out of Egypt. However, when the firstborn worshiped the Golden Calf, they lost their privilege and were superseded by the Levites, the only group who did not participate.
To transfer the Temple rights of the firstborn to the Levites, the firstborn were counted, and the Levites were taken as an exchange for them. Of the total number of 22,300 Levites, 300 were themselves first-born, and could not be used to redeem the other firstborn, so 300 firstborn had to redeem themselves with money.
We can see that the Levites and the Kohanim (who are members of the tribe of Levy) are exempt from the laws of firstborn with the "a fortiori" reasoning: if they could exempt other firstborn, then certainly they can exempt themselves. The firstborn donkeys are mentioned by the Torah in the same phrase with the human firstborn to tell us that their law is the same, that is, the Levites are free from the obligation of the firstborn donkey .
Art: Sir Lawrence Alma-Tadema - The Death Of The First Born