A Psalm of David, when he fled from Absalom his son. This is what the Scripture says (Proverbs 21:15), "It is joy to the righteous to do justice." It is joy to the Righteous One of the world when He executes justice, for He is exalted in the world, as it is said (Isaiah 5:16), "But the Lord of hosts is exalted in judgment." Another interpretation: It is joy to the Righteous One of the world when He executed judgment in His house and destroyed it, as it is said (Psalms 68:36), "Awesome is God from His Sanctuary."
Rabbi Yochanan said: If He did this to His Sanctuary, how much more so would He not show favor to others? Another interpretation: It is joy to the Righteous One of the world when the attribute of justice cleanses them from their iniquities. You can learn this, for David was struck by the attribute of justice, yet he began to rejoice and sing, saying, "A Psalm."