David appoints Solomon as King
1 Kings 1:28-30 (NKJV)
Then King David answered and said, “Call Bathsheba to me.” So she came into the king’s presence and stood before the king. 29 And the king took an oath and said, “ As the LORD lives, who has redeemed my life from every distress, 30 just as I swore to you by the LORD God of Israel, saying, ‘Assuredly Solomon your son shall be king after me, and he shall sit on my throne in my place,’ so I certainly will do this day.”
But the Law in Deutoronomy clearly states otherwise
Deutoronomy 21:15-17 (NKJV)
“If a man has two wives, one loved and the other unloved, and they have borne him children, both the loved and the unloved, and if the firstborn son is of her who is unloved, 16 then it shall be, on the day he bequeaths his possessions to his sons, that he must not bestow firstborn status on the son of the loved wife in preference to the son of the unloved, the true firstborn. 17 But he shall acknowledge the son of the unloved wife as the firstborn by giving him a double portion of all that he has, for he is the beginning of his strength; the right of the firstborn is his.
Did not the king break the law by appointing a younger son ahead of his brothers or there was some undue influence from Bathsheba.