David wanted to honor God by building him a temple. God told David that he would not build it, but his son would build it. (See: [[rc://en/tw/dict/bible/kt/temple]])
God made a covenant with David that was not conditioned upon anything David or his descendants did. God promised that one of David's descendants would rule Israel forever. Because Israel would not have a king in the future, this promise did not begin at this time. The descendant, who would rule forever, is Jesus. (See: [[rc://en/tw/dict/bible/kt/covenant]] and [[rc://en/tw/dict/bible/kt/promise]] and [[rc://en/tw/dict/bible/kt/eternity]])