David conquered the city of the Jebusites and named it Jerusalem. The traditions of the Middle East of that time was to have a capital city, especially a newly captured important city, that could also serve as the resting place of the national god.
David appears to have intended to follow the pattern. He had his palace built along with other necessary government buildings, and now he expected to place God in a new building befitting the God of Israel. Living in a tent could no longer be permitted.
As we read, God had other ideas. The tent will do nicely for now.
[1 Samuel 1:7,9 refer to “the House of the Lord,” but that should be taken as the tabernacle.]
God ordered David to be the Great king he was chosen to be and let his son build the Temple.
There is an important play on words in the Hebrew. David intends to build a bayit, a house for God, but God tells David through Nathan, The Lord declares to you that He, the Lord, will establish a house/bayit for you. JSB (verse 11b)
In the most lasting sense, David will build a house for God.
Two more important points. Verses 12-13: When your days are done and you lie with your fathers, I will raise up your offspring after you, one of your own issue, and I will establish his kingship. He shall build a house for My name, and I will establish his royal throne forever. JSB
Firstly, the house will be built for the Name of God. God cannot be tied to one place; He is God of the universe. It was one thing to lead Israel through the wilderness until they reached the summit of their destination. It would be un-Godly to limit Himself to one small city in one small kingdom.
Secondly, the two verses must be read as two-fold prophecies. The first regards Solomon and the second regards the Messiah. The bayit Solomon would build would only hold the Name of God, but the bayit of the Messiah would hold all the Children of God.
Be righteous and do good.