Even when a person receives divine forgiveness for a severe failure, the public consequences of their actions can still exact a heavy toll. Nathan the prophet clarifies to David that although his personal sin is forgiven and his life is spared, the act itself caused profound reputational and moral damage that demands a penalty. Out of respect for the Divine, the prophet speaks of the "enemies of God" as a polite substitute. In truth, David's actions directly scorned and angered God Himself, but the phrasing shifts the insult away to maintain reverence [רש״י, רד״ק, ביאור שטיינזלץ].
The primary approach among commentators is that David's actions provided an excuse for those who hate Israel. Wicked individuals could now justify their own behavior by pointing out that even the great leaders of Israel commit such deeds, resulting in a massive desecration of God's name [רש״י, רד״ק, מצודת דוד, אברבנאל]. Adding a more personal layer to this tragedy, David had previously been the one to publicly rebuke these very enemies for sins like shedding blood and taking the wives of others. The fact that he failed in the exact areas he once preached about makes his downfall particularly bitter [אברבנאל]. Another perspective suggests that the resulting disrespect actually stems from God's profound mercy. God chose to forgive David to teach future generations the power of repentance. Yet, this very act of forgiveness leads those who refuse to repent to further disrespect God, mistakenly assuming He simply tolerates such grave sins [מלבי״ם].
As a direct result of this public desecration, a fitting punishment is decreed: the child born to Bathsheba will die [מצודת דוד, ביאור שטיינזלץ]. This raises a question as to why God settled for this punishment rather than commanding David to immediately divorce Bathsheba. The explanation lies in the military practices of the time. Soldiers in David's army would issue conditional divorce documents to their wives before leaving for battle. Therefore, upon Uriah's death, it became retroactively clear that Bathsheba was an unmarried woman, meaning David did not violate the strict legal boundaries of taking another man's wife. God chose to keep the punishment private, allowing the child to pass away without broadcasting the underlying reason. A public command to divorce Bathsheba would have caused even greater damage to the honor of the monarchy and the Torah.
Ultimately, in the realm of divine wisdom, Bathsheba was always meant to be David's wife and the mother of King Solomon. David's error was acting on impulse and taking her prematurely. The first child, conceived in haste and sin, was like unripe fruit that was not meant to survive. In contrast, Solomon, who was born later at the proper time and under permitted circumstances, was chosen to continue the royal dynasty [אברבנאל, מלבי״ם].