2 Samuel 7:11
And as since the time that I commanded judges to be over my people Israel, and have caused thee to rest from all thine enemies. Also the LORD telleth thee that he will make thee an house. And as since the time that I commanded judges to be over my people Israel, and have caused thee to rest from all thine enemies. Also the LORD telleth thee that he will make thee an house.
The promise was given when David dwelt in his palace of cedar and Israel dwelt in costly houses, yet worship still centered in the curtained Tabernacle in Jerusalem, where the visible emblem of God's presence dwelt between the cherubim and where the ark made in the wilderness and carried from Horeb to Jerusalem through the forty years pilgrimage still remained. Seeing the contrast between his own magnificent palace and the poor provision for the ark, David was impressed with remorse that a more honorable place should be prepared for the worship of God, and he told Nathan the prophet of his conviction to build a temple, which Nathan encouraged him to carry out. God refused David's plan to build Him a house, because He had a special work and other service for David to perform instead. By divine appointment and providence, God selected David's son Solomon to accomplish the great work of building the temple.
In place of David building for God, God promised to make David a house, meaning not a physical building but the establishing of his seed, royal line, and throne into an enduring kingdom. God's refusal did not mean rejection; it came with assurance of divine favor and signs of love toward David, his descendants, and Israel. David answered the promise with gratitude and renewed his covenant with God.