We saw in chapter 15 the connection of the line of David, the hope of Israel, with the ark of the covenant/temple and the establishment of right and true worship of God. The Chronicler emphasizes this again in chapters 17 and 18 especially.
In chapter 17 we have the pronouncement of the messianic Davidic covenant, with promised fulfillment of David’s desire to establish true and right worship of God. In this desire, David wants to build a house for the ark of God. Instead of that God provides him with a promise of something greater. God says that a king will come from David’s line who will rule forever over God’s kingdom (v14), and who will build a house for God (v12), which means, by virtue of the house being built in an eternal kingdom established by God, the establishment of right and true worship of God forever. Jesus is that King, and we are his temple of worship in spirit and in truth, established before God forever.
The connection of the line of David with the temple specifically and the establishment of right and true worship of God in the temple is made in chapter 18, where in verses 8 and 11 David acquires materials that will eventually be used by Solomon to build the temple.
This Davidic connection to worship at the ark and the temple in chapters 15 and 18 is a message for the recently returned Israelites to reestablish right and true worship of God according to the Law of Moses, to honor God and receive blessing from him, in hope of the fulfillment of the messianic promise to David.
Jumping back to chapter 17, we see that David views this as all to the glory of God: “making for yourself a name for great and awesome things” (v21); “and your name will be established and magnified forever.”