Some liberal Christians and Jews look at the massacres described in the Old Testament (especially the book of Joshua) and try to console themselves by saying that, while the stories may be horrifying, they didn’t really happen. I agree with them there. The stories in the Torah and book of Joshua are pure mythology, and later books of the Bible are only partly historical. However.
The problem is that it’s very likely that the descriptions of Old Testament massacres, and divine commands to commit them, reflect how warfare was actually practiced at the time. One way we can tell this is by looking at ancient inscriptions describing the conquests of the kings of the time. Because key parts of the Bible were written during the period when the Assyrian Empire was dominant, I’ll give as my example of this some excerpts from an inscription made by the Assyrian king Shalmaneser III:
29b-33a) Moving on from the city Hubuskia I approached the city Sugunia, the fortified city of Aramu the Urartian. I besieged the city, captured (it), massacred many of its (people), (and) carried off booty from them. I erected two towers of heads in front of his city. I burned fourteen cities in its environs.
53′-64’a) Moving on [from the city] Gurgum I approached the city Lutibu, the [fortified] city of Haiiānu, the Sam’alite, Haiiänu, the Sam’alite, Sapalulme, (55′) the Patinean, [Ahunu], the man of Bīt-Adini, (and) Sangara, the [Carchemishite], put their trust in each other and prepared for war. They attacked me to do battle. With the exalted might of the divine standard which goes before me (and) with the fierce weapons [which] Assur my lord gave to me, I fought (and) defeated them. I felled their fighting men with the sword, [rained down] upon them [destruction (lit. “flood”)] as the god Adad, (60′) piled up their (bodies) in ditches, [filled the extensive] plain with the corpses of their warriors, (and) with their blood I dyed the mountain red like red wool. I took from them (lit. “him”) numerous chariots (and) teams of horses. I erected a tower of heads in front of his city (and) [razed, destroyed, (and)] burned [his cities]. I made a colossal royal statue of myself (and) wrote [thereon] about my heroic deeds [and victorious actions. I erected (it)] before the source of the River Saluara at the foot of the [Amanus] range.
(90′) Moving on from [the city …]ra I approached the city Dabigu. […], the fortified [city] of Ahunu, the man of Bit-Adini. I besieged (and) captured (it), I massacred their (people) (and) carried off booty from them. I razed (and) destroyed the city (and) turned it into a devastated ruin hill. (A. Kirk Grayson. 1996. Assyrian Rulers of the Early First Millennium BC II (858-745 BC). University of Toronto Press. pp. 8-11)
The Assyrians are a particularly interesting example because of the strange role they play in the Old Testament. On the one hand, they’re an important if often forgotten Old Testament villain: the Book of Micah hopefully looks forward to a future ruler who will be able to protect Israel from them. On the other hand, the authors of the Old Testament interpreted disasters suffered at the hands of foreign nations like the Assyrians as punishments for worshiping the wrong gods. So if the Assyrians laid siege to a city and the people started starving and eventually resorting to cannibalism, then in a sense it was God who was making them eat their own children.
It gets weirder once you realize that the Book of Deuteronomy has strong parallels to Assyrian vassal treaties of the time, with God filling in for the Assyrian Empire (See The Bible Unearthed, p. 281). And Deuteronomy commands Israelites (really the Judahites) to behave an awful lot like the Assyrians, destroying entire cities and slaughtering their inhabitants.
In other words, while the Assyrians are important villains of the Old Testament, they’re also an important sense the model for the Old Testament God. If the Israelites are bad, God will punish them using Assyria as his instrument. But if the Israelites are good, God will take on the role of their Assyrian overlord, and assist them in doing unto others as the Assyrians had done unto them.
That, in turn, means that while Joshua’s massacres didn’t really happen, they were the kind of thing that really happened back then, and while it’s not clear that King Josiah ever managed to do much massacring himself, it seems to have been something he thought was just fine and dandy and aspired to do until Necho II killed him.