This in it's entirety from the Watchtower May 15, 2005, page 31. You might find the reasoning a bit hollow.
Questions From Readers
Why were David and Bath-sheba not put to death for committing adultery, whereas their newborn son died?
The Mosaic Law stipulated: "In case a man is found lying down with a woman owned by an owner, both of them must then die together, the man lying down with the woman and the woman. So you must clear away what is bad out of Israel." (Deuteronomy 22:22) If Jehovah God had allowed the judicial case of David and Bath-sheba's sin to be handled by human judges under the Law, the adulterous couple would have been executed. Since the human judges could not read hearts, they were to render judgment on the basis of the conduct of the wrongdoers as established by the facts. An act of adultery called for the death sentence. The Israelite judges were not authorized to pardon that sin.
On the other hand, the true God can read hearts and forgive sins if he sees a basis for doing so. Since the case involved David, with whom He had made the Kingdom covenant, Jehovah chose to make an exception and deal with the matter himself. (2 Samuel 7:12-16) "The Judge of all the earth" has the right to make such a choice.?Genesis 18:25.
What did Jehovah see as he examined David's heart? The superscription to Psalm 51 says that this psalm reveals David's feelings "when Nathan the prophet came in to him after he had had relations with Bath-sheba." Psalm 51:1-4 states: "Show me favor, O God, according to your loving-kindness. According to the abundance of your mercies wipe out my transgressions. Thoroughly wash me from my error, and cleanse me even from my sin. For my transgressions I myself know, and my sin is in front of me constantly. Against you, you alone, I have sinned, and what is bad in your eyes I have done." Jehovah must have viewed this intense remorse in David's heart as an evidence of genuine repentance and decided, that there was a basis for showing mercy to the wrongdoers. Moreover, David himself was a merciful person, and Jehovah shows mercy to the merciful. (1 Samuel 24:4-7; Matthew 5:7; James 2:13) Hence, when David acknowledged his sin, Nathan told him: "Jehovah, in turn, does let your sin pass by. You will not die."-2 Samuel 12:13.
David and Bath-sheba were not to escape all consequences of their sin. "Because you have unquestionably treated Jehovah with disrespect by this thing," Nathan told David, "also the son himself, just born to you, will positively die." Their child grew sick and died despite the fasting and mourning that David carried on for seven days.-2 Samuel 12:14-18.
Some find it difficult to understand why the son had to die, since Deuteronomy 24: 16 states: "Children should not be put to death on account of fathers." But we must remember that if the case had been handled by human judges, the parents as well as the unborn child in the womb would have lost their lives. The loss of the son might also have helped David to realize more keenly how displeased Jehovah was with his sin with Bath-sheba. We can be confident that Jehovah dealt with the matter justly, for "perfect is his way."-2 Samuel 22:31.