The Lord did this because David did what the Lord considered right: David never failed to do anything the Lord commanded him to do his entire life (except in the matter concerning Uriah the Hittite).
I tore the kingdom away from David’s heirs and gave it to you. But you have not been like my servant David. He obeyed my commands and faithfully followed me by doing only what I considered right.
God removed Saul and made David their king. God spoke favorably about David. He said, ‘I have found that David, son of Jesse, is a man after my own heart. He will do everything I want him to do.’
Then he won’t think he’s better than the rest of his people, and he won’t disobey these commands in any way. So he and his sons will rule for a long time in Israel.
Please forgive my offense. The Lord will certainly give you, sir, a lasting dynasty, because you are fighting the Lord’s battles. May evil never be found in you as long as you live.