In Biblical times, the first-born males would be consecrated to the service of God, assisting the priests (similar to what Channa did with his son Shemuel). That was the tradition among the Jews and even among other nations, like the Egyptians, Babylonians. etc. Once the Tora was given to Am Israel, Aharon and his descendants were granted the Priesthood. They serve HaShem in the Mishkan (mobile sanctuary in the dessert or tabernacle) and later on in the Bet haMikdash. Following the ancient custom , the first-born males should have been appointed to assist the Kohanim. God Almighty, however, consecrated the tribe of Levi to assist the Kohanim. The Leviim were then responsible, for example, of assembling, transporting, maintaining the Tabernacle and many, many other chores related to the Sanctuary and its service. At the time the Leviim were appointed, the Israelite first-born males were ‘released’ from serving in the Sanctuary, however, they had to be formally redeemed by his parents from a Kohen.
This is a Biblical commandment, found in Bamidbar (numbers)18:15 (“You must redeem every first born…”).
The redemption is performed by given to a Kohen five silver coins, in accordance with the instructions given by the Torah in the next verse, in Bamidbar 18:16 “You should redeem them at the redemption price of five sheqels of silver“.
The equivalent weight of the five sheqalim is a 96.1 grams of pure silver (Rab Hayim Nae). The custom, however, is to round up the number to 100 grams of silver.
In our days, the Israeli government issues a silver coin, weighting 20 grams each, to be used for this Mitzva.