The superscript of this psalm states that it is "for the dedication of the temple." Most likely this superscript refers to the dedication of the second temple by the returned exiles (Ezra 6: 16). In that case the "I" of the psalm came to refer to the repatriated community and the "healing" experienced in restoration from exile. Still later the Jews included this psalm in the liturgy for Hanukkah, the festival that celebrates the rededication of the temple in the days of Judas Maccabeus after its desecration by Antiochus IV Epiphanes.
In singing this thanksgiving psalm, we praise God for deliverance from the brink of death (st. 1) and call all "who know his name" to praise God for unfailing mercies (st. 2). Recalling the LORD's chastisement for proud self-reliance (st. 3), the psalmist reiterates a prayer offered while standing at death's door (st. 4) and closes in praise to God for turning sadness into gladness (st. 5). James Seddon (PHH 15) prepared this versification sometime before 1969; it was first published in Psalm Praise (1973). Calvin Seerveld (PHH 22) provided stanza 4 in 1982 to provide a complete versification of the psalm for the Psalter Hymnal.
Bert Polman, Psalter Hymnal Handbook
The Catechism says that those who know Christ’s forgiveness are “to thank God for such deliverance” (Heidelberg Catechism, Lord’s Day 1, Question and Answer 2). As a result, “With our whole lives we may show that we are thankful to God for his benefits, so that he may be praised through us, and that we may be assured of our faith by its fruits, and so that by our godly living our neighbors may be won over to Christ” (Heidelberg Catechism, Lord’s Day 32, Question and Answer 86).