This is a very difficult verse.
God is a God of mercy. Old John Gill writes this about the verse.
Can we abide with this today?
Thou therefore, O Lord God of hosts,…. Of the armies in heaven, the angels, and of all the inhabitants of the earth; who are all under him, and at his dispose, and can do among them and with them whatsoever he pleases;
the God of Israel; of the people of Israel, literally understood; and mystically of all the elect of God, Jews and Gentiles. The former epithet is expressive of his power, this of his grace and goodness in a covenant way; and both encouraged the psalmist to address him on the following account:
awake to visit all the Heathen: either the wicked Israelites that rose up against David, and sought to take away his life, who behaved like Heathens towards him, and were accounted as such by him; and the petition is, that God would arise and punish them, everyone of them, according to their deserts: or else the Gentiles, properly so called, whom he desires the Lord would visit, either in a way of grace, by sending the Gospel to them, and taking out of them a people for his name, as he did, Act 15:14; foreseeing, by a spirit of prophecy, that the Jews would be rejected for their ill usage of the Messiah; See Gill on Psa 59:1, title: or in a way of punishment for their idolatry and impiety; and particularly the antichristian states and powers, called the Heathen, and Gentiles, and nations of the earth, Psa 10:16; may be here meant; whom God will visit for their idolatry, blasphemy, and bloodshed;
be not merciful to any wicked transgressors; that are perfidiously and abominably wicked, as Judas Iscariot, the Romish antichrist. The Targum renders it, “princes of a lie”; that speak lies in hypocrisy, and are given up to believe a lie, as the followers of antichrist. God is merciful to wicked men and to transgressors, but not to wicked transgressors; apostates may be meant, such as deal perfidiously and treacherously, as the word (o) used signifies; who sin wilfully and knowingly, after they have received the knowledge of the truth; sin against light and evidence, and obstinately and wickedly persist therein: who sin the sin against the Holy Ghost, the sin unto death, which is not to be prayed for, 1Jn 4:16; or otherwise this may seem to be contrary to the command and example of Christ, Mat 5:44.
Selah; on this word; see Gill on Psa 3:2.
(o) בגדי “perfide agentibus”, Junius & Tremellius.