And David said unto Nathan, I have sinned against the LORD. And Nathan said unto David, The LORD also hath put away thy sin; thou shalt not die. 14Howbeit, because by this deed thou hast given great occasion to the enemies of the LORD to blaspheme, the child also that is born unto thee shall surely die. 15And Nathan departed unto his house. And the LORD struck the child that Uriah's wife bare unto David, and it was very sick.
And it came to pass on the seventh day, that the child died. — 2 Samuel 12:13-15, 18a
I understand that it was a convention in Hebrew literature to say that God did things that He did not literally or at least directly do. Although I do not remember all of the exact data that I used to use in order to support this, it can be seen in Psalm 88, for example, where, in the first part of it, a man is praying that God relieve him of his illness, and, in the second part of it, says that God gave him the illness. It's also seen in Ezekiel 20, where God says that He is the one that caused the Israelites to practice paganism and their other sins (which the entire book of Ezekiel, and much of the rest of the Old Testament is dedicated to condemning them for), and then just after tells the Israelites to repent of that sin.
While I do not know exactly why this convention is used in Hebrew literature, I believe that it may be used in order to cause a person to remember God, and thus their sin, when they see or experience the consequence of their sin. Alternatively, it may simply be that this was how the Hebrews thought, and therefore God used this convention when He spoke to the Hebrews.
It is because of Ezekiel 20 that I myself can say that, when God said in 2 Samuel 12:10-11 that He would cause someone from David's house to have sex with his wives, he wasn't speaking literally. This is necessary to believe, because James 1:13-14 say that God does not cause anyone to commit evil; this is besides the fact that this idea is morally repugnant.
Could it be that, when the Scripture says that God struck David's son with an illness, this same convention is being used by the Hebrew author? Is it possible that the text does not mean that God literally killed David's child, but only says this to make a theological point? Is there anything in the text that may suggest this?
Also consider Deuteronomy 24:16 and Ezekiel 18:20.
The fathers shall not be put to death for the children, neither shall the children be put to death for the fathers: every man shall be put to death for his own sin. — Deuteronomy 24:16 ...
The soul that sinneth, it shall die. The son shall not bear the iniquity of the father, neither shall the father bear the iniquity of the son: the righteousness of the righteous shall be upon him, and the wickedness of the wicked shall be upon him. — Ezekiel 18:20
The latter verse teaches that a son cannot bear his father's iniquity, going further than simply saying that he cannot be punished for it. If God killed David's son to punish David, would that not be in violation of this rule?