In this chapter, the prophet Nathan rebukes David, and the son borne through David's adultery dies.
This chapter contains the second reference to the person Nathan. The first was when David asked Nathan if he could build a temple for the LORD. We know very little of Nathan's history or life, but we know that he is now in the extremely difficult position of having to rebuke the king. Samuel got away with rebuking Saul because Samuel anointed him king, but even Samuel was afraid for his life when the LORD commanded him to go and anoint David (1 Samuel 16:2).
It is likely that Nathan has less authority than Samuel, but at the same time David is a much less sinister king than Saul, and he shows considerable humility in his response to Nathan. David shows that he is not replying to Nathan, but rather is replying to the rebuke of God. David knows that Nathan is just a messenger and that David is a servant of God and is being called to account by his own master. This is important because otherwise, Nathan has no authority or standing to rebuke the king.
That said, Nathan tells David a parable to reveal David's sin couched in a language he would be most familiar with, using the language of shepherding animals. I think this is God's way of taking David back from the splendor of kingship and to his youth. God is saying to David, I made you king; your power and glory are only because of my actions. God is both indicting David for his crime, and also reminding him of the humility of his youth.
As a minor note, the most likely reason why David insists on the sinner paying back four times what he took (v. 6) is because that's what is in the law of Moses, cf. Exodus 22:1.
Then Nathan tells him what will happen because of his sin, and it is pretty harsh. First, "the sword shall never depart from your house" (v. 10), meaning that the rest of David's life (and perhaps the rest of his descendants' lives) will be filled with conflict and violence. Second, David's own descendants will fight against him and cause some of that strife mentioned in v. 10. Third, because David committed adultery in secret, other people will commit adultery with his wives in public, and it will be his "companion" who does this. This recalls to me the punishment of Saul, where God told Saul that his kingdom would be given to his "neighbor" (1 Samuel 15:28).
Fourth, and most immediately, the child borne from this adultery would die.
These things do not happen because God is punishing David, since verse 13 tells us that the LORD has taken away David's sin. It is the consequences of the sin itself that harms David, just as much as David's sin hurt Uriah.
I also think the contents of verse 14 are interesting. It talks about the "enemies of the LORD" learning about David's sin. Who are the enemies spoken of? In most cases, "enemies of the LORD" in the OT refers to the hostile nations in Canaan that are resisting and fighting against Israel. However, what David did to Uriah and Bathsheba was done in secret, and only his closest allies know of it. So it is unlikely that hostile nations would discover this sin. Therefore I think it's more likely that the "enemies of the LORD" in this case could be a reference to hostile spiritual forces, even though these are rarely mentioned in the OT.
The way I think about it is like this. God brought in Israel to the promised land both to reward Israel, but also to punish the Canaanites. The Canaanite tribes were being punished because of their many sins (see Gen 15:16). What this means is that if David sins and the LORD did nothing about it, then it would render his earlier judgments hypocritical. No human being would know about it, but the evil powers and gods of the Canaanites would "blaspheme" by accusing God of judging unfairly. I'm not certain about this, but it's the most consistent explanation I can think of at this time.
After this, David's child with Bathsheba becomes sick and dies, just as Nathan said, in spite of David's prayers and fasting. Nothing David does can change back what would happen to his son, but David's prayers and fasting could change his own heart and help him to never do anything like this again. I don't believe that David is being punished, but he is being disciplined. The distinction is that "punishment" is what God does to sinners to bring justice, making them suffer because of their sins. "Discipline" is when God brings retribution that is designed to correct a sinner, to change them and get them away from the sins. God will punish those who sin and do not repent, but because David was forgiven, he is not punished, but he is disciplined. Amongst other differences, God will punish people as the judge of the world, but he disciplines as a father. So not only is a different action, it also implies a different relationship with the person who is being so treated.
As I just said, the purpose of punishment is to bring justice, but the purpose of discipline is to bring correction. Justice can happen whether or not the person receiving it agrees, just as you can lock a man in prison against his will. But correction cannot happen against a person's will, because you have to agree to change in order to be corrected.
Therefore one of the most important things about this story is to see how David reacts to the LORD's discipline, and I think for the most part his reaction reflects the humility and devotion that we've seen in previous chapters. Unlike Saul, who argued three times with Samuel before admitting that he sinned by sparing the Amalekites, David repents almost immediately when confronted by the prophet Nathan. After that, he prays and fasts on behalf of his son, appealing to the LORD for mercy. Even though his son dies regardless, I think it shows that David is really turning to the LORD in a major way that shows he is responding correctly to the LORD's discipline.
David's servants expected that he would be devastated when the child died, which was common in their time just as much as it's common in ours. I don't think there can be any doubt that David cared about this son of his, but he was not fasting or weeping as a show to other people, but as a show to change the heart of God. When he saw that God did not change, then he saw no reason to continue fasting or debasing himself.
This chapter has another one of my favorite verses, v. 23, which says, "Can I bring him back again? I will go to him, but he will not return to me." This is another rare OT reference to the afterlife, where David implies that death is, in some way, a reunion between those who have died. While David's son cannot return to him, David can nevertheless "go to him" when he dies. This is a favorite verse to me because it rephrases death. Rather than viewing death as a subtraction, taking our life away, David sees his death as an addition, something that will bring him back to his son.
Verses 24-25 are short but important. Solomon will eventually be David's successor to the throne, and the LORD has already "loved him". We see talk about Solomon a lot more later on.
Lastly, Joab defeats the Ammonites and sends for David to come and take the honor of victory. The Ammonites are enslaved and become servants of Israel. More importantly, we see once again that David is not showing the military prowess of his youth. He depends on Joab to strike down the Ammonites and it is only because of Joab's loyalty that David is brought in to have the honor of defeating the Ammonites. David is showing himself to be an increasingly weak king. He is still devoted to the LORD, but he is weak politically. This is an ominous sign, because we know from Nathan's prophecy that people from David's own household will fight against him, and his weakness in responding to them will be a serious vulnerability to his reign. It is only by the LORD's mercy that he is not killed; as Nathan says, he will not die prematurely.