After surviving a period of deep distress, a person naturally feels a profound need to express gratitude to God. Standing before the Temple, the singer calls out, asking to be let inside to offer his thanks. The primary approach among commentators is that this is a direct request to the gatekeepers of the Temple. The singer asks them to open the physical doors so he can enter the sacred space and present his thanksgiving offerings [ביאור שטיינזלץ, מצודת דוד, מלבי״ם, המאירי].
The entrance is associated with justice and righteousness for a few conceptual reasons. One perspective is that offering thanks to the One who provided salvation is simply the just and proper action that a person is obligated to do [אבן עזרא]. Another approach focuses on how God operated in this specific situation. The salvation arrived only after a period of suffering, meaning God acted through strict justice and careful judgment based on the person's deeds, rather than through pure, unearned kindness [מלבי״ם].
Alternatively, the request to open the doors can be understood metaphorically. Instead of physical gates, the singer is turning to the wise scholars of his time, asking them to help him unlock the right words so he can compose a fitting song of praise to God [רד״ק]. Another interpretation links this moment to the historical dedication of the Temple. According to this tradition, the Temple doors miraculously refused to open until the merit of King David was invoked. In this light, David himself is declaring that the sacred gates are opening specifically for him and because of his righteous standing [אלשיך].
Ultimately, the clear goal of entering the sacred space is to offer praise. The singer wishes to stand inside the Temple and thank God for saving his life and performing wonders on his behalf. This act of gratitude is meant to be highly public. By giving thanks in front of the community, the singer publicizes the miracle and magnifies God's name for everyone to see [ביאור שטיינזלץ, מצודת דוד, המאירי].