The word “impute” means “count” or “take account of”. So, “blessed is the man against whom the Lord will not count his sin” (ESV).
Paul here is using Old Testament examples to explanation how we can appear before righteous before God. He cites the example of Abraham, who “believed God and it was counted to him as righteousness” (Rom 4:3; cf. Gen 15:6). Abraham wasn’t sinless but he trusted in God and this was counted as righteousness.
Then Paul cites the example of David, who writes in the psalms “blessed are those whose lawless deeds are forgiven, and whose sins are covered; blessed is the man against whom the Lord wil not count his sin” (Rom 4:7-8; cf. Ps 32:1-2). David wasn’t sinless but his sins were forgiven and were not counted against him.
This is the way that we can be righteous before God. If God forgives our sins then they are not counted against us. If we trust in God then that faith will be counted as righteousness.