It is perfectly logical that once David had the Ark of God on location in Jerusalem, he then desired to build a temple in which to house it. It was a wholesome intent (I Kings 8:18), but despite the prophet's acquiescent attitude toward the idea, God vetoed it because of the nature of David's calling (I Chronicles 17:4-6). David was a man of war (I Chronicles 22:7-8). Now, despite God's unwillingness to allow David to construct a temple in His name, He was not displeased with the young king (I Kings 8:18). In fact, He allowed David to collect all the necessary materials in preparation for the building of a temple and then permitted David's son Solomon to erect the edifice.
When David offered to build God a house, God turned things around on David and promised to build him a house instead and to build a house for the whole nation of Israel. Of course, God truly did not need a temple anyway. All of heaven can’t contain Him. God seeks after us, invites us, pursues us, persuades us, prepares us, convicts and convinces us… and, when we finally respond with an offer to serve Him, we always end up discovering that He is the giver, not us. God built David a house instead of letting David build Him one. The gospel is truly about what God has done, is doing, can do and will do for us; not the other way around.