A common occurence in the Bible, as god repeatedly ordered the Israelites to eradicate this or that group of people completely, supposedly to allow the "chosen ones" to get land that they deserved. Remember that one of the worse war crimes imaginable was supposedly repeatedly ordered by someone who is considered to be a loving and benevolent god.

Another explanation was that the Hebrew people of the time were just very warlike, and justified their killing by convincing themselves and each other that some god thought them special and that they were supposed to do all this killing. (A reversal of the causality - the personality of their god created to fit their actions, not their actions to fit the orders of their god.)

Genocide is a horrible thing, regardless of the reason, as there cannot ever be a good reason.