This is quite possibly the hardest things to understand in the Bible. Some people may turn to the book of Joshua and read the stories of the Israelite conquest in Canaan to find some pretty ruthless campaigns. At first glance it seems unnecessary and over the top. Without CONTEXT, you can get a real different sense of the God of peace and mercy that is heralded.
The first and most important piece of context is from God Himself. In Genesis 15:16 He says, “And they (the Israelites) will come back (from Egypt) here (the land) in the fourth generation, for the iniquity of the Amorites is not yet full.” Paranthesis mine.
We see here that God sends His own people into slavery and oppression so that He doesn’t judge the Amorites prematurely. Doesn’t seem irrational or tyrannical, does it?
Next, in Deuteronomy we see Moses reiterating the Sinai laws and covenant to the Israelites before they cross over the Jordan river to take the land. Strikingly, in Deuteronomy 9:4 Moses tells them, “Do not say in your heart, after the LORD your God has thrust them out before you, ‘It is because of my righteousness that the LORD has brought me in to possess this land’, rather it is because of the wickedness of these nations that the LORD is driving them out before you”
Here we see that God is not arbitrarily ordering the murder of nations. These nations have sinned against God generation after generation, more than 400 years, and at last God is judging them. His instrument of judgement is the nation of Israel who He promised to give the land after their conquest.
The final point I’d like to make to show that God is not racist or an evil tyrant is from another passage in Deuteronomy. In Deuteronomy 20 Moses says, “When you draw near to a city to fight against it, offer terms of peace to it. And if it responds to you peaceably and it opens to you, then all the people who are found in it shall do forced labor for you and shall serve you.”
Even here we see an extra length of mercy. If they didn’t want to fight with Israel, they lived; they were then made to work for them.
Clearly, God did not arbitrarily order genocide. The biggest help in understanding is context. Read the first 6 books of the Bible straight through and it is much easier to understand. You wouldn’t pick up a novel, start reading halfway through, and put it down because in one chapter a character wasn’t “nice”. You’d read before and after to get the whole picture or read from beginning to end-like normal.
Hope that helps! I hope this helps you answer other people asking you these hard questions.
Soli Deo Gloria