Not that anyone asked, but here is my opinion on the matter:
(And please, hold off on the rotten tomatoes)
BLASPHEMY
The verse at 2 Samuel 12:14 Clearly states that David's sins in relation to Bath-Sheba would give occasion for God's enemies to blaspheme God ( some versions use the word “contempt” ). God had already made it clear that profaning His Holy Name is a serious sin deserving of death (Leviticus 24:16). It was also made clear in the Ten Commandments that anyone who abuses God's name was to be held guilty (Deuteronomy 5:11). David was aware of these Godly laws, as revealed in his words at Psalms 40:8, in which he said: "I delight to do thy will, O my God: yea, thy law is within my heart. " (KJV); therefore David couldn't claim ignorance of these things.
Now, David was the chosen anointed king handpicked by God Himself (1 Samuel 16:1-13, 2 Samuel 2:4, 10-11). Being God's chosen King he had a serious responsibility as a leader of God's people. This Bath-Sheba/Uriah situation, however, showed great disrespect for God's blessings (2 Samuel 12:8-9), contempt for God's laws, and made a mockery of the God-chosen kingship, resulting in profaning God's Holy Name. This is why the whole affair would give opportunity for blasphemy against Him.
This baby was the physical manifestation of David's disrespect, contempt, and mockery (ie blasphemy) against God. For as long as this baby existed the blasphemy against God would continue to exist. And, as we've seen earlier, David was quite cognizant of God's standards and knew that blasphemy could not be tolerated. God did not put this baby into this predicament, it was David who did this. This is why the death of the baby falls squarely on David's shoulders, not God's.
THE TEN COMMANDMENTS
There is also the matter of how many of the Ten Commandments David broke when he committed this string of sins. The first thing he did was covet his neighbor's wife (Exodus 20:17). Since coveting is the same as idolatry (Colossians 3:5), David also broke that commandment too (Exodus 20:3). Since idolatry requires an idol of some sort ( in this case, Bath-Sheba's body ), that commandment was also broken (Exodus 20:4-5). The next thing he did was commit adultery with his neighbor's wife (Exodus 20:14). Considering that adultery is tantamount to thievery (Psalms 50:18), he also broke the commandment against stealing (Exodus 20: 15) (2 Samuel 12:9). After this, he attempted to deceive by trying to cover up his paternity of the resulting child (Exodus 20:16). Lastly, he committed the sin of murder when his other plans failed (Exodus 20:13). All of this sin, scandal, and murder would have been a complete dishonour to his family, especially to the parents who raised him -- thus he also broke the commandment regarding the honouring of one's parents as well (Exodus 20:12).
So let's count this up:
1.Covetousness -- He lusted after another man's wife. 2. Idolatrous behaviour -- He sent for her to come to his room.
3. Idol -- Bath Sheba's body was the implement of his idolatrous actions. 4. Adultery -- The intimacy with another man's wife. 5. Stealing -- He took the wife that belonged to Uriah. 6. Lying -- He attempted to cover up his paternity 7. Murder -- He killed the innocent husband.
8. Dishonouring parents -- His parents could not have been proud of his actions.
This means that in total, David's actions broke eight of the Ten Commandments in this one situation. David was God's chosen leader for the Israelite nation -- therefore this brazen disregard for so many of the Ten Commandments over one incident was not something to take lightly. Unfortunately, the baby was the physical proof of all these sins. God's pure Holiness cannot tolerate such a filthy stain on the leadership. This reflects back to the profanity against God's Holy Name; this stain needed to be removed.
Again, David caused this situation for the baby, not God.
LEGAL REPERCUSSIONS
Beyond the sullying of God's Holiness, beyond the breaking of most of the commandments, there is also the fact that the royal human ancestry of Jesus Christ was to come only through the line of David (Isaiah 11:10, Matthew 1:6-16). Since Bath-Sheba was still married to Uriah when David impregnated her, the baby would have been legally recognized to be of the house of Uriah in the Israelite culture. Think about it: Bath-Sheba surely gave birth long before her ninth month of marriage to David, thus people would have realized she conceived during her marriage to Uriah, thus the people would have considered this baby to be the child of Uriah. This would mean that the baby would have inherited Uriah's estate and holdings even though David sired him. On top of this, since the Messianic line was supposed to come through David, and not Uriah, this was making more of a mess of things regarding the legal paternity of the child. Imagine the inevitable confusion that would occur when it came to deciding who ascends the throne, who inherits Davids holdings, and who would be listed in the human ancestral line of Jesus Christ.
Note, also, that the Bible continues to speak of Bath-Sheba as the "wife of Uriah" while the child remained alive, even though David had already married her (2 Samuel 12:15). It wasn't until after the child was dead that Scripture refers to her as the wife of David (2 Samuel 12:24) as all legal connection to Uriah was then completely dissolved.
Realize that this wasn't just an ordinary incident of an adulterous liaison resulting in pregnancy; this particular baby whom David fathered had unwantingly become an intruder into the Royal Messianic line; and such an intruder could not be allowed to remain because the royal lineage must remain pure. God's plan could not be obstructed as the entire future of mankind was at stake – in order for God's plan to succeed, this situation needed to be removed for the good of all mankind. Again, it was David who thrust the baby into this situation, not God.
WHERE IS THE BABY NOW?
Although this baby boy was a casualty of David's blasphemy this doesn't mean this baby was eternally damned. Note that God could have damned the baby by ending the pregnancy at any timeas He had no obligation to let the baby be born. (This is not to suggest that miscarriages and stillbirths are the will of God).
And this is where God's love is found in all this mess:
God allowed the pregnancy to come to full term so that the baby could have a full week of life. By allowing that baby to live, even for such a brief amount of time, that baby was eligible to be covered under Christ's blood when Christ was sacrificed centuries later. In other words, even though that baby boy was the embodiment of blasphemy, God recognized his innocence and saved him through Christ's blood anyway. God's love is that beautiful. Hallelujah, and Amen.
AND.... it is worth noting that God Himself also had to endure the death of His very own son for the good of mankind. God isn't going to put us through something that He isn't willing to go through Himself.