@YJ,
God needs no excusing or defense from me. The very thought of my excusing God for something is absurd. Hecks rightly pointed to the passage in Job that underscores this.
I am merely trying to explain a right perspective on what happened to jamiet, in hopes of removing an obstacle to his believing the truth. I presume that his question was asked in a spirit of honest inquiry, and am attempting to answer in that spirit.
@jamiet,
"However, God kills the baby before it actually commits any such acts, surely? So at the point at which God murders it, the baby has not sinned. No?"
A great question, and one I don't know the answer to (though David, at least, held, although in precisely what sense is unclear, that he was sinful from conception). Whatever the spiritual and moral life of infants, it is in any case such that it is not wrong of God to introduce them to a world where they are subject to death. As I said before, a great many infants die. If it is not wrong of God for Him to let those infants die when he is not directly punishing any action (or at least we're not told that He is), how could it be more wrong for Him, vis-a-vis this infant, to cause its death when punishment of an act WAS one of his motivations? If He's not wronging a baby when it dies, then He's not wronging a baby when it dies. And if He is, then He is. (He's not).
Your moral intuition, I think, is coming from human-perspective morals. Humans do owe each other life in the sense that it is wrong of them to take each other's lives (except in capital punishment). God owes us no such thing. Life is an undeserved, indeed, anti-deserved gift, and God does not wrong us when He removes it.
"Yes, but what we're talking about here is your concept of justice. I put it to you that God's decision to kill this particular baby, which has done nothing wrong (and has not sinned), in order to inflict a punishment not on the baby, but on someone else, is fundamentally unjust. I challenge you to defend how this can possibly represent, as you put it "dealing justly" with the baby."
He dealt justly with the baby because He did not take any actions on the baby that He had no right to take. It would be wrong of us humans to punish somebody other than the person who committed a crime, because we have the right to punish another human only when that human has committed murder or some such crime.
God, on the other hand, owes life to nobody. Restricting attention only to His interactions with the baby, and leaving David and everybody else out of it, we find that the child was born, and soon died. In this, God did not violate any duty toward the baby (unlike the case of us, if we killed the child).
I hope that is helpful at all.