After King David had settled in his beautiful palace, and things were peaceful on the battle front, David started toying with the idea of building a temple to match his palace. However God spoke to David through the prophet Nathan that this wasn't what God desired. To the contrary God's concern was with David's "house" or dynasty and not with physical constructions. God wanted to establish David's "house" so that there will be Davidic kings long after his own death, promising to establish his lineage and throne forever. This covenant is a foundational promise for the lineage of the Messiah, Jesus Christ.
David replied to God in prayer questioning who he was to be so blessed? He exalts the greatness of God asking who is like the Lord and who can be compared with the nation of Israel? David yet praises the sovereignty of God and the trustworthiness of his word which assures him that the house of David will be blessed forever.