The first order of business for a newly freed Israel was to make order out of disorder. These individuals had never governed themselves - they were slaves and their governance was done for them. God laid out the laws for the people to help them create order from chaos, peace from conflict. This particular law helped establish the order of inheritance, so that internal family conflicts could be minimized.
Fun fact - firstborns have more fun. I am a firstborn. It is awesome. I got to do everything first - confirmation, driver's license, college, kids. I got to forge the way, make the mistakes, learn from them. It's a lot of responsibility, too. I feel responsible for making sure my little sister doesn't make the same mistakes as I did. I feel like I need to be strong for her. But every now and then I let her be strong for me, too. I love my sister and I tell her a lot. Let today be the day you appreciate your siblings, or the people you love like siblings.
If a man has two wives, one of them loved and the other disliked, and if both the loved and the disliked have borne him sons, the firstborn being the son of the one who 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 firstborn in preference to the son of the disliked, who is the firstborn. He must acknowledge as firstborn 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 firstborn is his.