He did this because David had done what he approved and had not disregarded any of his commandments his entire lifetime, except for the incident involving Uriah the Hittite.
When all Israel heard about the judicial decision which the king had rendered, they respected the king, for they realized that he possessed supernatural wisdom to make judicial decisions.
“Son of man, prophesy against the shepherds of Israel; prophesy, and say to them – to the shepherds: ‘This is what the sovereign Lord says: Woe to the shepherds of Israel who have been feeding themselves! Should not shepherds feed the flock?
After removing him, God raised up David their king. He testified about him: ‘I have found David the son of Jesse to be a man after my heart, who will accomplish everything I want him to do.’