I have struggled a lot with this question over the years, and I think that I have found some peace with it. In addition to some of the really good explanations offered earlier on in this thread I would also like to add the possibility of having to see these events in context, and by that I mean that we should see them in their proper perspective, bearing in mind the times in which they happened.
If we take the emotion out of it, does it not make perfect sense for even a loving and all-powerful God to use a remedy for that specific problem in the language of the times? Our sensitivities are conditioned to accept things like negotiations and attempts at trying to avoid violence. Let’s be realistic about this for a while - would it really have worked in that time for God to order the leaders of Israel to go and negotiate with their enemies? To write them a letter? To report them to the UN? I’m really not trying to be facetious, but what else would have worked? Add to this, still under the heading of context, the undisputable fact that God also had to make an impact on his chosen people. It is, in my view, a sad fact of those times that tough, hard-living humans would have had more respect and would have been more prone to following a “tough” God, one who could show real power, or at least how that was perceived at the time. Would a soft-spoken, reasonable God, one who could debate issues well and who cuddled bunnies really have “impressed” the chosen people?
I suppose what I am trying to show is that a wise and omniscient God MUST know what type of action speaks best to a chosen person / people at a specific time. I believe that, by taking the events of those times out of context, we make things a lot more muddled for ourselves.