Uriah, his wife and the child born to Uriah's wife are just plot devices.
Or maybe there was a King David who became remorseful after doing away with his friend and taking his wife, after he discovered that his advisor, and who knows who else were aware of what he had done.
Perhaps the point of the story is the contrition and great lengths the King went to in order to regain God's favor. Maybe David and everyone else did attribute the baby's death to God even though such deaths were not uncommon.
If so, what can be learned from the story? Isn't the story, like many of the Old Testament stories about David and his relationship to God? We see that David does not blame God despite his belief and eventually we might understand that David's contrition was real.
Under a government which imprisons any unjustly, the true place for a just man is also in prison. Thoreau: Civil Disobedience (1846)
History will have to record that the greatest tragedy of this period of social transition was not the strident clamor of the bad people, but the appalling silence of the good people. Martin Luther King
If there are no stupid questions, then what kind of questions do stupid people ask? Do they get smart just in time to ask questions? Scott Adams