He begins the psalm by revealing how much he loves the mercy and justice of God. David knew that he was a sinner, yet he also had discovered that God could pardon him and simultaneously uphold justice. This is a reminder that the Lord is gracious, that he does not treat us in the way our sins deserve. Instead he punishes a substitute. And our substitute was Jesus on the cross. David, who looked ahead to the coming of the Saviour, praised the Lord for his mercy.
David’s longing was for fellowship with God (v. 2). In order for that to happen, David realised that he had to have certain attitudes. His home life had to be of a high standard (v. 2), his interests had to be on important matters (v. 3a), he had to hate sin (v. 3b), and he had to separate himself from all that is wrong (v. 4).
In verses 5-8, he describes his rule. He will bring down those guilty of slander and pride (v. 5). He would enact laws that would encourage the faithful because he knew that such were a benefit to society (v. 6); indeed he would choose his counsellors from among them (v. 6). As king, he would never have deceivers in his home (v. 7) and he would consistently aim to rid the land of evil people (v. 8).
David here is a picture or type of the Lord Jesus whose universal rule is marked by holiness. He is also a picture of a true ruler, of one who fears God as he rules over his subjects. When we have rulers who run their homes and their public lives according to God’s Word great blessing can come on a people.