Ezekiel 18:24
But when the righteous turneth away from his righteousness, and committeth iniquity, and doeth according to all the abominations that the wicked man doeth, shall he live? All his righteousness that he hath done shall not be mentioned: in his trespass that he hath trespassed, and in his sin that he hath sinned, in them shall he die.
When the righteous turns away from his righteousness to commit iniquity and do according to all the abominations that the wicked does, he shall not live, for all his righteousness that he has done shall not be mentioned, and in his trespass that he has trespassed and in his sin that he has sinned he shall die, and that death is just. Past righteous deeds will not count against the guilt of later sin and will not save the one who dies in sin after abandoning righteousness. Turning from righteousness to commit iniquity means the former righteous life counts for nothing.
In the investigative judgment the books of record are opened and the lives of all who have believed on Jesus come in review before God, from the first who lived upon the earth through each successive generation to the living, with every name mentioned and every case closely investigated for acceptance or rejection. When anyone has sins remaining upon the books unrepented and unforgiven, the name is blotted out of the book of life and the record of good deeds is erased from the book of God's remembrance. Unrepented and unforgiven sins remain on the record while the record of that person's good deeds is erased.
Those who go against God's light and oppress others cannot be assured that all will be well, because God sees their actions and will judge them for their choice. Past righteousness does not excuse present wrongdoing, and the one who turns from righteousness and commits sin is accountable for that sin. Former good deeds do not atone for present unfaithfulness. Faithfulness in an earlier year or earlier period cannot make up for neglect now, just as truthfulness yesterday cannot make up for falsehood today.
Long years of advocating truth, past trials, obedience, faithfulness, and genuine experience with God give no entitlement to reward and no covering for present neglect. Those with such a past are more guilty before God if they fail to preserve integrity and go forward to perfection, and self-complacency over former service stands condemned. David's earlier integrity and favor did not excuse or justify his later crimes nor prevent God's judgment and punishment. Though he repented and confessed and was forgiven with his life spared and part of the threatened calamity averted, punishment still followed.