"When you enter the land the Lord your God is giving you and have taken possession of it and settled in it, and you say, 'Let us set a king over us like all the nations around us,' be sure to appoint over you a king the Lord your God chooses. He must be from among your fellow Israelites." (Dt 17:14-15)
“The Lord declares to you that the Lord himself will establish a house for you: When your days are over and you rest with your ancestors, I will raise up your offspring to succeed you, your own flesh and blood, and I will establish his kingdom. He is the one who will build a house for my Name, and I will establish the throne of his kingdom forever. I will be his father, and he will be my son."
The second, the "negative" view is found in First Samuel:
"But when [the elders of Israel] said, 'Give us a king to lead us,' this displeased Samuel; so he prayed to the Lord. And the Lord told him: “Listen to all that the people are saying to you; it is not you they have rejected, but they have rejected me as their king. As they have done from the day I brought them up out of Egypt until this day, forsaking me and serving other gods, so they are doing to you. Now listen to them; but warn them solemnly and let them know what the king who will reign over them will claim as his rights ...” (1 Sam 8:6-9)What's the deal - if the Israelites' desire for an earthly king was a rejection of God's kingship, why would He consent? How could he then speak of David's kingdom as part of His plan to bless the world? God doesn't change His mind or make things up as He goes along. Jesus birth into the world as the kingly son and successor of David was God's eternal plan.
And therein lies the resolution - the Incarnation resolves the apparent contradiction. The Lord could consent to the Israelite desire for an earthly king, while ultimately remaining their only King, because at the end of David's kingly line was the God-Man, Christ Jesus! "Oh, the depth of the riches of the wisdom and knowledge of God! How unsearchable his judgments, and his paths beyond tracing out!" (Rm 11:33)