Okay, I'll forget about the 'judging the morality of first temple Israelites' thing. For fun, let's talk about the Joshua 'kill all the cattle and everything that breathes' story. I'm going to make an educated guess as to the reasoning behind some of Joshua's behavior on the basis of what I know about warfare several centuries after the time of the action of the story (when, in any case, this story was probably written).
Joshua is the story of the eponymous warlord of the Israelites after their arrival in the Levant and after the death of Moses. The Israelites had been living as nomads and had decided, for whatever reason, that the Levant was the place they would settle down. Unfortunately, the Levant was occupied and controlled from several city-states ruled by kings. Joshua's army totally annihilates (down to the cattle) a couple of cities, Jericho and Hazor. The question is why.
The Israelites had until now been living as a nomadic tribe, moving through pretty poor territory and subsisting largely by pillage or by the contributions of or extorsions from allies. This means that Joshua's army has no redoubt, and no consistant source of food or men or materials for fighting. His aim is to settle the Levant permanently, and to do so he has to oust the occupying people.
This means he cannot tolerate a series of long sieges: his army is living off the crops sown by the people he is attacking and if his invasion of a certain territory lasts more than a year, his army will starve. People need to surrender, and surrender immediately. Joshua has to find a way to communicate this message to his enemies, and in these days the only form of mass communication is to do something interesting enough to be gossiped about.
What do you do if you want to convince a whole region full of people that the game has changed, and that you're no longer pillaging and threatening? So long as people think you're coming for wealth and food, they'll fight you because they think you're making a cost/benefit analysis: if they cause you more trouble then their cattle are worth, you'll go away. So long as everyone is thinking about warfare in terms of materials gained and lost, you're pirate and a nomad and they're the homeowners. But you're trying to move in, and quickly, so you need to send a serious message.
The way to do this is to kill every living thing in a city. Everything. If you keep the cattle, then people will think you're after the cattle. But if you 'offer the city up to god' and kill every living thing, that's when people stop thinking of you as a pirate. That's when they start realizing that they need to leave, and leave now. Because you're not going to be satisfied with wealth, and you're not going to take your time. You're the unstoppable terror, and you're here for good.
Joshua sends this message twice. First when he arrives in the region, with Jericho. Second, when the kings of the northern part of the Levant (the really nice part) get together to fight back, with Hazor. Fighting back is not allowed. Each time, the total annihilation was about sending a message, about saying 'Stop fighting. We're not going to be bought off, or sated by plunder. It's over for you. Get. Out.' Again, Joshua needs to send this message fast and loud because he has, tops, a few years before every Israelite is a slave or dead or scattered to foreign parts. The enemy needs to feel like it's fighting a storm, or a god. Something with no pity, and no mercy, something that does not rest or negotiate.
I'm no student of strategy, but this doesn't seem to me to be foolish or irrational. It also doesn't seem to me that this involves anything like 'turning off your morality'. Was any of this immoral? I dunno, this is kind of how warfare works, and for Joshua, it was this or death. It seems to me to be a well thought out strategy, and one that was very successful. Within a generation, the Israelites ruled the Levant. Within five, they were one of the greatest regional powers, capable of sitting at the table with Egypt and Babylon. And the civilization they established became one of the greatest cultural heavyweights in history, probably matched in the ancient world only by vedic India and classical Athens.
Yes, you've reinvented the classic economic/game-theoretic justification for total war - pour encourager les autres. This reasoning was more or less the explicit goal of the Mongols when they did things like build pyramids of skulls, and I've read economic analyses of New World pirates in which the Jolly Roger served a similar intimidation function. The tactic works best when coordination is hard, because if the intended victims can coordinate, such extremism may prompt the formation of an effective alliance against oneself even by parties who would've preferred to remain neutral.
If it's worth saying, but not worth its own post (even in Discussion), then it goes here.