"Sanctify to Me every firstborn, the first issue of every womb among the children of Israel, of man and beast, is Mine (Ex. 13:2)".
'Smiting of the Firstborn' was the tenth and culminating plague in Egypt. Ex. 13:15 specifically cites it as the underlying rationale for the above commandment. Across cultures, firstborns have ever enjoyed a special status. Hence, the plague's doubly devastating impact on the Egyptians. That plague miraculously differentiated between their and Israelite firstborns, the former smitten, the latter spared. These thus incurred additional obligations, both to gratitude and servitude to God. That reinforced their traditional leading role in spiritual matters. Indeed, that was the dynamic behind Jacob's desperate desire for such service, coupled with his elder twin brother's Eau's dismissive disdain for it, that impelled the latter's sale of his 'birthright' (Gen. 25:29-34).
Due to the incident of the Golden Calf (Ex. Chap. 32), the firstborn lost that revered role. While that great sin seems to have arisen from alien elements, who had joined the Great Escape from Egypt, they seemingly encountered scant resistance from the Israelite masses. By contrast, the tribe of Levi subsequently stalwartly demonstrated their fealty to the Sinaitic Covenant. Perpetuation of authentically-based worship clearly dictated the need for a far more restricted, hereditary, sacerdotal class. That was to be the Levites. And, even within that tribe, despite his own unfortunate, if well-intentioned, involvement in that act of apostasy, Aaron and his descendants were singled out as a special priestly family ('Kohanim'), their lives to be totally immersed in divine service.
After a general census of the other tribes (Num. 1:2-4), there were separate counts of Levites (Num. 3:14-16) and Israelite firstborn (Num. 3:40-43), from one month of age and upward. That was followed by a formal transfer of sacred status from the latter to the former (Num. 3:44-51). There were 273 more firstborn Israelites than Levites. Randomly selected "excess" firstborn redeemed themselves by payment of "five silver shekels (20 geras)" each "to Aaron and his sons" (Num.3:47-48). That was in accordance with the valuation of living beings enumerated in Lev. 27:6 - "If from one month to five years of age, the valuation of a male shall be five silver shekels". The reason, incidentally, for restricting the count to thirty days and onward, was that it depended on the viability of the newborn.
Given the Biblical basis for the Pidyon HaBen ceremony, it might be imagined that its performance would be quite common. But it is not. It is estimated that only about ten percent of Jewish nuclear families experience it. The child must be male, naturally delivered, and the first born of the mother, who must not have previously suffered a post first trimester miscarriage. Neither Kohanim, Levites, or the firstborn of their daughters, are to be redeemed from their inherent consecration. Where redemption is required, if a father neglects to perform this rite, responsibility falls on the son to do so once he attains religious maturity.
The ceremony itself takes place any time after 30 days, inclusive of the day of birth, typically on the thirty-first, unless that day falls on the Sabbath or work-restricted Holiday. Fulfillment of the commandment is actually quite perfunctory, involving just the handing over of the pure silver equivalent (117 grams) of five shekels. In the U.S. silver content dollar coins, or special issue Israel mint coins, are normally used. A synagogue or other organization may provide them. While their actual source does not matter, the coinage used must be an unconditional gift to the Kohen. He is free, if he wishes, as is the norm, to return them to the provider.
In practice, the ceremony has become more elaborate than that. It is held in conjunction with a festive meal ('Seudas Mitzva'). Those assembled are seated. After the meal commences, with the blessing over bread ('Motzi), it is interrupted. The baby is brought in on a silver tray, adorned with jewelry. A brief dialogue, in Hebrew and Aramaic, then ensues between the father and Kohen:
Father: This is my firstborn son; he is the first issue of his mother's womb and the Holy One, Blessed is He, has commanded to redeem him as it is said:
"And those who must be redeemed, from the age of a month are you to redeem, according to your estimate, five silver shekels in the shekel of the Sanctuary, which is twenty gerah" (Num. 18:16). And it is said: "Sanctify for Me every firstborn, the first issue of every womb among the Children of Israel, both of man and of beast, is Mine"(Ex.13:2).
Kohen: Which do you prefer: to give away your firstborn son, who is the first issue of his mother's womb, or do you prefer to redeem him for five shekels as you are required to do by the Torah? (this is purely rhetorical)
Father: I wish to redeem my son. I present you with the cost of his redemption as I am required to do by the Torah.
Holding the redemption money, he then recites two blessings:
"Blessed are You, HaShem, our God, King of the Universe, Who has sanctified us with His commandments and has commanded us
regarding the redemption of a son". and
"Blessed are You, HaShem, our God, King of the Universe, Who has kept us alive, sustained us, and brought us to this season".
The Kohen accepts the money and, while swinging it, over the infant's head responds:
This is instead of that; this is in exchange for that; this is pardoned because of that. May this son enter into life, into Torah and into fear of Heaven. May it be Your will that just as he has entered into this redemption, so may he enter into Torah, the marriage canopy, and good deeds. Amen.
He then places his hand on the child's head and blesses him:
"May God make you like Ephraim and Manasseh (Gen. 48:20)".
"May HaShem bless you and safeguard you. May HaShem illuminate His countenance for you and be gracious to you.
May HaShem turn His countenance to you and establish peace for you (Num. 6:24-26)"
"For lengthy days and years of life, and peace shall He increase for you (Prov. 3:2)"
"HaShem will protect you from every evil, He will guard your soul (Ps. 121:7)"
The Kohen then returns the child to his father, takes a cup of wine, and recites the standard blessing over it.
The festive meal the resumes, to be followed by the standard Grace after Meals.
Though the newborn has now been redeemed from priestly and levitical roles, however in abeyance those currently are, as an Israelite, he, nonetheless, retains his noble birthright as a member of a "kingdom of priests and holy nation (Ex. 19:6)".