CLAIM: David says, “For I have kept the ways of the Lord, and have not acted wickedly against my God. 23 For all His ordinances were before me, and as for His statutes, I did not depart from them. 24 I was also blameless toward Him, and I kept myself from my iniquity” (2 Sam. 22:22-24). How can this be the case, when he was found guilty of murder and adultery (2 Sam. 11)?
RESPONSE: David knew that he had sinned before. When Nathan rebuked him, he said, “I have sinned against the Lord” (2 Sam. 12:13). In Psalm 51, he admitted, “I know my transgressions, and my sin is ever before me. Against You, You only, I have sinned and done what is evil in Your sight” (vv.3-4). Thus David wasn’t clueless over his sin. Instead, David’s focus here is on the grace of God in light of his failures. Later in the chapter, David says, “You save the humble” (v.28), and “The Lord turns my darkness into light” (v.29) and “He is a shield for all who take refuge in him” (v.31). Thus, he must be showing that God has made him purified for his failures.
Another view is that David was speaking in a hyperbolic sense. He might be looking back on his life of faith, and he is saying that he has followed God for the entirety of his life. At the very least, we learn that David isn’t sin-focused at the end of his life.