God's right to the firstborn sons of Israel is anchored in the story of the exodus. Since God spared Israel's firstborn, God says that they "shall be mine." In some ancient religious practices, this might have meant human sacrifice, but God rejects that option and allows instead that the firstborn be "redeemed" or bought back (see Exodus 13:11-16; Numbers 18:15-16). Here in Numbers 3, God accepts the Levites, a tribe not included in the census for service for war or in the distribution of land, as "substitutes" for Israel's firstborn (see also 3:40-51).This will be part of the basis for the Levitical priesthood.
The exodus narrative, picked up here in Numbers, gives a historical basis for the common offering to God of all first fruits (for example, Exodus 23:19; Numbers 18:13; Deuteronomy 18:4). Returning to God the first fruits of creation acknowledges that all belongs to God and is graciously given by God. Some have seen the story of Abraham's near-sacrifice of Isaac as another indication that, though once people thought the sacrifice of a firstborn child was appropriate, God will instead "redeem" the child through another form of sacrifice (Genesis 22:1-19).
11 Then the Lord spoke to Moses, saying: 12I hereby accept the Levites from among the Israelites as substitutes for all the firstborn that open the womb among the Israelites. The Levites shall be mine, 13for all the firstborn are mine; when I killed all the firstborn in the land of Egypt, I consecrated for my own all the firstborn in Israel, both human and animal; they shall be mine. I am the Lord.
New Revised Standard Version Bible: Anglicized Edition, copyright © 1989, 1995 National Council of the Churches of Christ in the United States of America. Used by permission. All rights reserved worldwide. http://nrsvbibles.org