The Spirit of the Lord was with David and with other prophets before Christ's earthly birth in Bethlehem and continues to guide us today. His word is within us and He, as God, is unfailing.
"David was conscience-stricken after he had counted the fighting men, and he said to the Lord, "I have sinned greatly in what I have done. Now, Lord, I beg you, take away the guilt of your servant. I have done a very foolish thing." (2 Samuel 24:10, NIV)
It really is only God Who can truly forgive sins.
I will surely carry out this very day what I swore to you by the Lord, the God of Israel: Solomon your son shall be king after me, and he will sit on my throne in my place." (1 Kings 1:30, NIV)
Even in his oldest age, David sought to correct his mistakes, as much as possible.
"and observe what the Lord your God requires: Walk in obedience to him, and keep his decrees and commands, his laws and regulations, as written in the Law of Moses. Do this so that you may prosper in all you do and wherever you go" (1 Kings 2:3, NIV)
Rich or poor, this is where our blessing lies; with walking in obedience to the Lord, seeking the guidance of Holy Spirit!