How did the "...in exchange for your first-born son!" trope start?

by Handyland
Deathsquid

Just trying to spitball a conversation here, but didn't your firstborn son have most rights to inheritance and property for multiple cultures and time periods?

I mean, that is speculated to be one of the origins for marriage and the existence of the term "bastards", is to maintain a clear line of property ownership and inheritance.