What does Exodus 13:15 mean?
Pharaoh was stubborn and wouldn't let us go, so the Lord killed every firstborn in Egypt—both people and animals. That's why I sacrifice every firstborn male animal to the Lord and buy back my firstborn sons. Exodus 13:15 - Modern Text Bible
(The ritual is a direct response to what happened in Egypt, both as a warning and a sign of gratitude.)