2 Samuel 7:6
Whereas I have not dwelt in any house since the time that I brought up the children of Israel out of Egypt, even to this day, but have walked in a tent and in a tabernacle. Whereas I have not dwelt in any house since the time that I brought up the children of Israel out of Egypt, even to this day, but have walked in a tent and in a tabernacle.
The words look back to the whole history since the Exodus, when God brought the children of Israel up out of Egypt and from that time to David's day had not dwelt in any house but had walked among them in a tent and in a tabernacle. That curtained tabernacle was the place where the Shekinah, the visible emblem of His presence, dwelt between the cherubim, and out of the perfection of beauty God shined. The ark that had been constructed in the wilderness and borne all the way from Horeb to Jerusalem during the forty-year pilgrimage still remained in the tabernacle.
At that time the sanctuary and its services were still at Gibeah, while the ark was in a separate place. The nation of God's choice had been greatly favored, yet they dwelt in costly houses while they still worshiped God in the curtained tabernacle. While dwelling in his palace of cedar and beholding the costly dwellings of the inhabitants around him, David was impressed with remorse that he dwelt magnificently while the ark, which symbolized the mighty God and Maker of heaven and earth, was housed so much more poorly, and he desired to prepare a more honorable, permanent temple in Jerusalem for God's worship.
When David made his convictions known to Nathan the prophet, Nathan encouraged him to carry out his purpose of building a temple for the Lord to dwell in. God did not grant David that task, but in His providence selected David's son Solomon to accomplish the great work of building Him a house. By divine appointment the temple was later built in Jerusalem nearly three thousand years ago. David's sincere intention was refused because God's plan was different, yet God still blessed and used him and entrusted him with another special work and service to perform.