David took the throne, took Jerusalem, got a palace and now wanted a temple for his God:
1 Chronicles 17:1; 2 Samuel 7:1-2 When King David was settled in his palace and the Lord had given him rest from all the surrounding enemies, the king summoned Nathan the prophet. ‘Look’, David said, ‘I am living in a beautiful cedar palace, but the Ark of God is out there in a tent!’
God had a different idea:
1 Chronicles 17:5-6 I have never lived in a house, from the day I brought the Israelites out of Egypt until this very day. My home has always been a tent, moving from one place to another in a Tabernacle. Yet no matter where I have gone with the Israelites, I have never once complained to Israel’s leaders, the shepherds of my people. I have never asked them, ‘Why haven’t you built me a beautiful cedar house?’
As God pointed out, he didn’t need a house. He was happy with a tent, even though it might not have looked as grand as a king would have liked.
We later learn that one reason God didn’t want David to build a temple was David’s hand in killing too many people: in war and probably in peace (e.g. Uriah the Hittite). It was going to be left to Solomon to build it.
Note
Here’s the scriptures covered in this section, broken up and recast into chronological order:
2 Samuel 7:1–17; 1 Chronicles 17:1–15; 2 Samuel 7:18–29; 1 Chronicles 17:16–27; 2 Samuel 8:1–14; 1 Chronicles 18:1–13; Psalm 60