David Tells Nathan of the Cedar Houseby emmanuel_higgins

2 Samuel 7:3

And Nathan said to the king, Go, do all that is in thine heart; for the LORD is with thee.

David was dwelling in his palace of cedar and looking upon the costly houses of Jerusalem when he was impressed that a more honorable place should be prepared for the worship of the great God, the Maker of the heavens and the earth. He was filled with remorse that he himself dwelt in a magnificent palace while provision for God was so much poorer. The ark, which symbolized the mighty God, had been constructed in the wilderness and borne from Horeb to Jerusalem during the forty years pilgrimage, yet it still remained in the curtained tabernacle where the Shekinah dwelt between the cherubim, housed far more poorly than David himself. When David made this conviction known to Nathan, Nathan answered in the verse by encouraging him to carry out his desire and purpose to build a temple for the Lord to dwell in, assuring him the Lord was with him.

Nathan's encouragement was not God's direction, for that night God told Nathan that David would not build the temple. God barred David from building because he had shed much blood and fought many wars. God had a special work for David himself to perform, and in His providence He had selected David's son Solomon to accomplish the great work of building Him a house.