These passages in the Bible are a gripping narrative. There are so many details and so many lessons to be learnt but we are confining ourselves to some of the bigger aspects. So many things stem from bad moral choices. Sin always has consequences, and those consequences can last for our whole life.
Just a few matters to note before we come to the main theme, but Joab now has great influence and power over David. As a result of his being made privy to David's desire to murder Uriah, David is now in a weak position before his nephew. Likewise, David's efforts to follow the Lord will now be unconvincing to a number of people. They will say that he is a hypocrite and that he is no longer to be taken seriously. But the judgment of God against David's sin, as spoken by the prophet Nathan, find their exact fulfillment in the rest of David's life. He will experience in his own family sexual immorality, murder, and betrayal.