This article gets a few things right but the author doesn't seem to understand the full purpose of characters like David in the Bible. You don't even have to believe they were real people or be religious, much less Christian, to see and understand their purpose.
Right in the beginning in the Eden narrative there's a prophecy about one who will ultimately defeat the snake. Characters like David are portrayed as anointed by God yet flawed because they are supposed to build anticipation for a true Messiah or Christ who will not make mistakes or sin and really, truly offer redemption for mankind and a return to union with God. As you read the Bible you watch each leader rise while hoping they will be the one to defeat the snake and then you return to anticipating the true king when they fall.
This is one of the reasons Jesus was consistently referred to as the "Son of David."
Jesus is presented as the true and greater version of every flawed leader of God's people who came before him, especially the big names like Noah, Moses and David.
What's interesting to me is that you don't even have to agree with the claims of the Bible to see how the characters function in the story. But as I've learned more and more about the Bible, it seems that most people make arguments about the claims of the Bible or its purpose as a religious text without understanding how it actually functions as a group of different stories and types of literature.
For anyone interested, Robert Altar's works about Biblical narrative and other literary styles delve deep into these subjects.