In general writing things afterward helps them learn from where they came from. I didn't quite process holding onto God over the people, but He is a constant in this. You can watch what happens when the obey and when they stray. So building a new nation with a God foundation.
David was certainly flawed, but could also rise up with God behind him. Pointing out the flaws with success could also give hope of what is yet to come out of destruction.
Maxwell
Your statement of being “perfectly flawed” stuck with me. Definitely David was flawed but he still was called to a perfect calling. I think the reference to curcumcision is also poignant in this time when scripture was written. God being faithful as you mention is definitely something we can agree that appeals to the masses. It’s that thought process that possibly allowed these miracles to occur in scripture. The faithfulness of God to Gods people that even through tough trials is definitely appealing especially in this current time in our world.
Peace
Calvin
as i noted in another post, some interpreters see the Law and not David as the hero of the DtrH.
even even a perpetual dynasty is subject to the rewards and punishments, then monarchy takes second place to obedience to divine law.
look at Deut 17:14-20