Having described God's rescue of him, here in the heart of the psalm David describes how God justifies him. David describes a life of perfect obedience to God - a life that David himself was incapable of living, because of his sin. Yet in speaking of a perfect King, David points us forward to his Son, the Lord Jesus (see Acts 2:30, Luke 24:44). By faith in him, we too can be justified in God's sight!