King David didn’t always do what was right, he sinned when his focus was not on the Creator. Psalm 119:105—106, “Your word is a lamp to my feet and a light to my path. I have sworn and confirmed that I will preserve Your righteous judgments.” David’s repentance, humility and willingness to serve the Creator preserved his throne.