David had been victorious over his enemies--internal as well as external ones. He has been made king over all of Israel. He has brought back the ark of God from where it had been hidden during the battles. they put the ark in a tent and made offerings to the Lord.
David is living in a house and decides that the ark should have a house as well.
The Lord tells Nathan what to tell David about this idea.
The Lord is responsible for the beginning of David's story, his success against his enemies, and for David's future. David has it backwards if he thinks that it depends on him to provide a house for the Lord.
The Lord will build David's house.
The house and kingdom shall last forever.
A problem arises for us as we read these verses. David's son, Solomon, did build a temple--that was destroyed by the Babylonians. After the return of the exiles, a temple was built to replace it. Did the people think that God meant only for David not to build a temple? How did we discern that great houses of worship are appropriate and helpful?
We usually read the word "house" in this section to also mean "family." That is, we interpret God's promise to mean that David's descendants would rule Jerusalem forever. How long is forever? Foreign powers overtook their land. David's house was taken into captivity.
Another problem with the promise of forever. Would that mean that no matter what David or his children, grandchildren, and great (and so on) grandchildren did, that God would remain in relationship with them, provide for them? That is, does sin matter to God? Are we not being help responsible for our actions? See 1 Kings 9:4-7 for a statement of the conditional covenant).