There is much speculation about why God called David “a man after My own heart” (1 Sam. 13:14; Acts 13:22). This seems strange given his sin with Bathsheba and the fact that God said he was a “man of war” who has shed much blood (1 Chron. 22:8). Perhaps it was because David was a king who executed judgment and justice over all his people (see Isa. 56:1; Prov. 21:3), and yet he knew how to show mercy, as he did with King Saul when it seems he could have justifiably killed him.
1 Chronicles 18:14 So David reigned over all Israel, and administered judgment and justice to all his people.