Kevin DeYoung:
Everyone who knows the Bible knows that King David was a great man.
And yet everyone familiar with the Bible will also recognize that David did a lot of not-so-great things. Of course, there was the sin with Bathsheba, the murder of her husband Uriah, and the subsequent cover-up. That was not exactly delighting in the law of the Lord (Psalm 1:2). But there was also the ill-advised census motivated by David’s pride, not to mention a series of lessons in how not to manage your household well. For being a man after God’s own heart (Acts 13:22), David managed to follow his own heart quite a bit.
So with all these flaws, what made David great?
The rest here.