“‘When the LORD brings you into the land of the Canaanites, as He swore to you and your fathers, and shall give it to you, you shall set apart to the LORD all that first opens the womb. All the firstborn of your animals that are males shall be the LORD’S. Every firstborn of a donkey you shall redeem with a lamb, or if you will not redeem it, you shall break its neck. Every firstborn of man among your sons you shall redeem. And [when the day comes that your son asks you],* “What does this mean?” you shall say to him, “By a strong hand the LORD brought us out of Egypt, from the house of slavery. For when Pharaoh suddenly refused to let us go, the LORD killed all the firstborn in the land of Egypt, both the firstborn of man and the firstborn of animals. Therefore, I sacrifice to the LORD all the males that first open the womb, but all the firstborn of my sons I redeem.” It shall be as a mark on your hand or frontlets between your eyes, for by a strong hand the LORD brought us out of Egypt'” (Exodus 13:11-16).
Because of the events of the Passover (the firstborn sons and beasts of Egypt dying), God required the Israelites to sacrifice their firstborn of their flocks. Their firstborn sons, however, would be selected for redemption—saved from the sacrifice (God repeats this in Numbers 18:15). “Redeem” means to “pay off” or “buy back.” Thus, God would “buy back” the firstborn sons of Israel with the sacrifice of a lamb.
Ultimately, God would require this sacrifice of Himself. He sacrificed His “firstborn”—His only-begotten Son—as the Lamb of God to redeem, that is, buy back His human creatures from sin and the devil (John 3:16). Being risen from the dead, Christ is therefore the firstborn from the dead (Colossians 1:18), meaning many are to follow His resurrection, including you and me. Saint Paul says that by Baptism, we are united with Christ in a death like His and shall therefore be united with Him in a resurrection like His (Romans 6:3-5). With Christ being the firstborn of the resurrected, God adopts many as His children through the birthing waters of Baptism through which His children follow Christ in His resurrection. Whether adult or infant, God redeems His people through sharing in the Baptism of His only Son.
*My own translation because the ESV translation is terrible.