The psalm is about David’s illness. He felt like the Lord had left him. But the Lord was good, he came back and gave him life again. Why was the temple destroyed? Because God had left his people. And the dedication to the temple was to celebrate that the Lord came back again.
1 I will extol you, O LORD, for you have drawn me up and have not let my foes rejoice over me.