The psalmist begins by crying out to God over the destruction of Jerusalem (1-4). (This must have been written after Babylon invaded in 587 B.C.) Imagine foreign soldiers rampaging the Lincoln Memorial - this is something of how he feels.
He knows that he and his people are sinful (8). Therefore he does not question the punishment. His plea is about how long God’s judgment will last (5). He asks God to instead divert his attention and wrath to the nations who don’t know Him (6). And in the place of further judgment on God’s people, he requests three things:
First, that God would not hold against them their prior “iniquities” (8). Iniquity is a sin that harms everyone else within its blast radius. He acknowledges they got what they deserved - they harmed each other in their iniquity, so Babylon showed them what that feels like. Thus the psalmist now simply prays for mercy.
Secondly, he prays for God’s glory (9-10). God needed to “take a loss” in order to justly deal with His own House (see 1 Peter 4:17). But now he prays for God to reverse that and get much glory for Himself, by bringing justice upon Israel’s tormentors. This is the wisest way to pray; God’s glory is God’s highest desire.
Lastly, the psalmist remembers the unique place of God’s people, and he returns to a future-facing faith (11-13). “But we your people, the sheep of your pasture, we will give thanks to you forever. . .” Psalm-making resets us back into the stance of future-facing faith in God’s incoming mercies, in answer to our prayers.