The Bible does not attempt to hide the shortcomings and sins of its main characters and authors. The heroes in Scripture (besides Jesus) are those who have had some serious moral problems. Abraham lies, Moses murders, Rahab is a Harlot, David commits adultery, Peter denies and Paul persecutes. Why were these included in the Bible?
The fact that the Bible includes the sins of its main characters helps to enforce its authenticity, veracity and credibility. If the Bible was manufactured in a way to deceive, its main characters and authors would be presented as being morally flawless...but they are not, they are “real”.
The Bible authors gain nothing from recording their sins except shame... yet, they are willing to risk ridicule and shame while authentically presenting the facts of what occurred.
“Real” people are often the most credible witnesses.
“Therefore, since we are surrounded by such a great cloud of witnesses, let us throw off everything that hinders and the sin that so easily entangles. And let us run with perseverance the race marked out for us” (Hebrews 12:1)