Deuteronomy 21:16
when that man assigns his inheritance to his sons he must not appoint the son of the beloved wife as the firstborn over the son of the unloved wife.
What it says
When distributing his inheritance, he must not treat the beloved wife's son as firstborn over the true firstborn.
What it is doing
It forbids preference from altering legal status.
In context
15If a man has two wives, one beloved and the other unloved, and both bear him sons, but the unloved wife has the firstborn son, 16when that man assigns his inheritance to his sons he must not appoint the son of the beloved wife as the firstborn over the son of the unloved wife. 17Instead, he must acknowledge the firstborn, the son of his unloved wife, by giving him a double portion of all that he has. For that son is the firstfruits of his father’s strength; the right of the firstborn belongs to him.