After removing Saul, he made David their king; He testified concerning him, "I
have found David, son of Jesse a man after my own heart; he will do everything
I want him to do."
1 Samuel 13:14
But now your kingdom will not endure; the Lord has sought out a man after his
own heart and appointed him leader of his people, because you have not kept
the Lord's command.
Now David has famously been considered a man after God's own heart. Yet, we should recall, David massacred village after village, putting even women and children to the sword during his wandering in Phillistine territory. Now we know deceit and treachery are how war works, of course, but some of the people David lied to were priests who served the Lord (see 1 Samuel 21). Feigning madness saved David's life but we know David took Bathsheba and arranged for Uriah the Hittite to be killed. David also failed to punish his son Amnon for raping Tamar, his daughter. This lack of executing justice for an incestuous rape spurred Absalom to kill his half-brother. David, again, did nothing.
Absalom bided his time and exploited the lack of judicial appointments in the region as a way to win the people over to his campaign against his father. Finally even Ahithophel, David's counselor, probably nursing a long grudge against what David did to his grandson-in-law Uriah, sided with Absalom's insurrection. Absalom was furious about very real failures to establish justice within the royal family and he exploited a real weakness in the reign of David regarding regional judicial oversight. Yet he followed Ahithophel's advice to take his father's concubines in public to make himself odious to the king. The prophetic warning from Nathan was coming to pass.
In the midst of this David had been cursed by Shimei
As King David approached Bahurim, a man from the same clan as Saul’s family came out from there. His name was Shimei son of Gera, and he cursed as he came out. He pelted David and all the king’s officials with stones, though all the troops and the special guard were on David’s right and left. As he cursed, Shimei said, “Get out, get out, you murderer, you scoundrel! The LORD has repaid you for all the blood you shed in the household of Saul, in whose place you have reigned. The LORD has given the kingdom into the hands of your son Absalom. You have come to ruin because you are a murderer!”
Then Abishai son of Zeruiah said to the king, “Why should this dead dog curse my lord the king? Let me go over and cut off his head.”
But the king said, “What does this have to do with you, you sons of Zeruiah? If he is cursing because the LORD said to him, ‘Curse David,’ who can ask, ‘Why do you do this?’”
David then said to Abishai and all his officials, “My son, my own flesh and blood, is trying to kill me. How much more, then, this Benjamite! Leave him alone; let him curse, for the LORD has told him to. It may be that the LORD will look upon my misery and restore to me his covenant blessing instead of his curse today.”
So David and his men continued along the road while Shimei was going along the hillside opposite him, cursing as he went and throwing stones at him and showering him with dirt. The king and all the people with him arrived at their destination exhausted. And there he refreshed himself.
David by this point realized God had brought about the disaster he was facing, that Nathan had warned him about. As grisly as the story of Absalom's insurrection is, the king's reign spirals downward. One of David's last acts was to take an ill-advised census that cost tens of thousands of lives. In 1 Kings we see David's final years characterized by impotence of every kind. His declining health was taken by Adonijah as the basis from which to appoint himself king. An elderly David is told he promised Solomon would have the throne. David does not recall the promise and has his son appointed king. Adonijah freaks out. David gives some final words of advice to Solomon, kill this and that guy. Solomon does. David's final years are demonstrations of royal impotence and hedging and advising Solomon to rely on his wisdom. Unfortunately as the rest of Kings demonstrates it's a live question whether Solomon relied on the wisdom he received from the Lord or his own wisdom.
David never really became a better husband to most (or any) of his eight wives. He never stopped playing favorites and being reluctant to discipline his most wicked sons. He never managed to feel strong enough to prevail against the often ruthless Joab. He was willing to massacre whole villages, including women and children. He pretended to be insane because he feared death. Christians who reflect just on the Bathsheba incident and the arranged death of Uriah the Hittite are arguably picking one of David's failures that's comparatively sedate in terms of actual scale of sin.
But David's sin with Bathsheba sticks out because Nathan specifically rebuked him for it. And what was the core of the rebuke? David stood guilty of having used his role and power as king to gratify himself. He used the power that was meant to serve and protect Israel as a means to self-gratification and self-aggrandizement. This would seem small but it wasn't to David because David was confronted with the reality of a trajectory--who before him had taken advantage of the perks and powers of royal office without carrying out the responsibilities of battle that went with it? Who let other people fight the battles he was commanded to fight for him while he did his own thing? Who arranged for the death of loyal and innocent people to protect his position and reputation? That's, right, Saul. Nathan confronted David about the reality of who David was becoming and when David was confronted with the reality of what a scoundrel he was he admitted he was a scoundrel.
Years later when David's own son was seeking his life and had built an insurrection on the objection to David's failure to punish evil David realized this was from the Lord. He'd seen how his own failures as a father and king had borne fruit in the disaster that came up to face him. He sought the Lord and sought the Lord knowing that he was dealing with the consequences of his own evil. During this time, readers may be aware, Absalom did not necessarily ever become the good guy. He had his own self-aggrandizing agenda and his own egotism. He did not become the good guy for being genuinely and rightly outraged at his father's unwillingness to pursue justice for the rape of Tamar or for letting Absalom go free after murdering Amnon due to fatherly favoritism.
But anyone who looks over the life of David will notice that David repented but he had to keep repenting. By contemporary standards of Christian piety and ethics, especially in American evangelicalism it looks like David was never a "one woman man" like Saul was, he never seemed to be the kind of parent Saul might have been to produce a son like Jonathan. David could be, as a certain music pastor at a local church put it, a guy who comes off like a self-absorbed whiny emo boy. Yet David was regarded, in advance of all these things, as a man after God's own heart. People who think it's impossible for God to appoint a scoundrel, a polygamist whose marriages had bluntly pragmatic military and political goals, a murderer, an adulterer, and an inattentive father who alternatley neglected and spoiled his children to lead God's people just haven't bothered to pay attention to the Bible. This could be said even though Shimei was not exactly right that David killed the house of Saul.