“If a man has two wives, one of them loved and the other disliked. If both the loved and the disliked have borne him sons, the first-born being the son of the one that is disliked. Then on the day when he wills his possessions to his sons, he is not permitted to treat the son of the loved as the first-born in preference to the son of the disliked, who is the first-born. He must acknowledge as first-born, the son of the one who is disliked, giving him a double portion of all that he has. Since he is the first issue of his virility, the right of the first-born is his.”
Perhaps it was common practice to have more than one wife. Liked or disliked, the first-born is the first-born with all its rights. The first-born gets double the portion of the others. This is reminiscent of the sons of Isaac, Esau and Jacob, where Jacob took the rights away from his older twin brother.