On a number of occasions, David and the other psalmists claim for themselves an innocence that appears to be unwarranted. Was not David guilty of grievous sins, and did he not know it (Psa 51)? Are we all not at best forgiven sinners, for whom protestations of innocence are always and entirely out of place?
This issue is helpfully discussed by Christopher Ash in Volume One of Teaching Psalms (chapter 6). Here’s a summary.
We meet those who can be referred to as ‘righteous’ as early as Psalm 1:5.
On the one hand, there is a righteousness that belongs to God alone (Psa 5:8), and which cannot be shared by any human being (Psa 143:1).
Yet, on the other hand the Psalmists to speak of their own righteousness (Psa 7:8; 18:20-24; 35:24).
The righteousness of the Psalmist, Ash argues, is, first of all, an imputed righteousness. It is a righteous status that comes from not having his sin counted against him (Psa 32:2). Paul teaches the same thing in relation to Abraham: faith in God is reckoned as righteousness (Rom 4:1-8; Gen 15:6). David’s righteousness, then, is not ugly Pharisaic self-righteousness, but rather a trust in the Saviour who was to come, in whom God’s covenant promises are all ‘Yes’ (2 Cor 1:20). We are righteousness ‘in Christ’, in the one who was totally without sin (Jn 8:46). Thus in Christ we can pray for vindication (Psa 17:2), trusting that God will forgive us out of his justice, as well as his mercy (1 Jn 1:8f), and even vindicate us on the last day, Lk 18:8.
But there is another aspect to this. There is not only an imputed, or alien, righteousness, but also an imparted, or actual, righteousness. David could speak of and claim an actual integrity and innocence (Psa 1:6; 7:8; 18:20-24; 37:21; 106:3). A work of grace produces a change of life. But it is precisely those who take refuge in God who can make such claims (Psa 5:11f). The righteous are not smug or self-satisfied: rather, they cry out to the God who hears and delivers them (Psa 34:17f; 94:21). So, for the believer, it is not the terrors of the law, but rather the grace of God in Christ, that brings about a change of life.
All of this can be seen in Psalm 32.