Here's a Christian apologist trying to justify old testament genocide (Joshua 6:20-21):
"This, generally speaking, is how Christian theologians have interpreted the Old Testament “ban” (Hebrew cherem). This term refers to God’s strict commandment to grant the heathen no quarter, to take neither prisoners nor spoil, but to destroy everything found in the cities of their enemies. Repulsive as it sounds to us today, this ruthless brand of warfare was not technically “genocide.” Not in the modern sense of the term. According to most biblical scholars, it was actually an expression of God’s judgment upon the Canaanites." *
Sorry, but this word salad is nothing more than trying to put lipstick on a pig, and that's putting it lightly. The justification begins with the premise that God cannot do wrong; that he can toy around with his creation as he sees fit. And that the concept of needing to eliminate any threats of sin influencing his chosen people somehow requires them being snuffed out. A very fitting description of a god contrived in the minds of ancient authors creating angry and jealous spiritual entities that they think everyone should bow to. Cuz, well, MY god is better and more superior than YOUR god.
Blood-soaked religions use this backdrop of sacrifice for dealing with sin (either for ethnic cleansing, and/or salvation). It's very telling, for example, that many of the south American cultures (including the Maya and the Mexican) believed that human sacrifice nourished the gods. These brands of religion survived eons of criticism because mankind has an innate need to be guided by a father figure that both intimidates and comforts us.
All these qualities of an easily explained story have strong underlying archetypical elements of salvation and eternal life. Stockholm syndrome, really. Very understandable how it has such a grasp on our psyche. A cursory study of our subconscious archetypes go a long way in explaining all this... It takes a lifetime of unearthing and becoming aware of these influences in order to extricate oneself from their control and grasp. Once done, you are free to be an independent thinker...
* Reference: https://www.focusonthefamily.com/family-qa/christian-struggles-with-biblical-accounts-of-genocide-and-holy-war/