e may normally view justice as something that God exacts on us from His throne. In reality, judgment is both God's business and our self-inflicted wound (Jeremiah 2:19 & Psalm 9:16). God does indeed distribute righteous verdicts constantly, yet our sins are their own punishment too. In many situations, the consequences for the vice are so obviously attached to the infraction that any observer would have to say, "You did this to yourself!"
Now, David was no stranger to justice. As the king of Israel and as a lifelong military man, he understood well the nature of maintaining law & order. In many cases, God has delivered the administration of equality into the hands of men (Gen. 9:6 & Rom. 13:3-4).
Essentially, David was praising God because of His righteous character. Because God is righteous He will eventually balance every scale, right every wrong, defend every victim and punish every infraction (Ecclesiastes 12:14). He investigates every crime and keeps perfect records (Psalm 9:12 & 18). Only those who approach Him in humble faith will receive mercy (Romans 6:23). But even in our pardon, He still maintains perfect justice (Romans 3:26). And, that should make us rejoice (Psalm 9:14). God isn't soft on crime. He is a perfect deliverer. He is a healer of repentant criminals, defender of victims and destroyer of heathen (Psalm 9:15 & 17).