During this period, God's sanctuary was the temple in Jerusalem. In God's presence, the psalmist receives special insight (compare Psalm 18:6).
God deals with the wicked over the long term. He waits patiently and gives them time to repent (Ezekiel 33:11; 2 Peter 3:9). Those who do not repent will get what they deserve.