This subject is a controversial one, one that stumped me for years until I realized the fallacy of the question. If God is the creator of all, the Heavens and the Earth, the stars in the sky, the science by which the earth is measured, and the creator of the moral good, it is inconceivable that God would act in an immoral fashion. In short, He that is morally right in every situation cannot act in a manner opposite to His good. In short: If God commands judgment on entire swaths of people or nations, it is not genocide but righteous adjudication. It is not only justified but warranted and good.
This might seem like an oversimplification but I have included authors who make a more drawn-out case. Paul Copan wrote an excellent book on this called “Is God a Moral Monster” and I included an interview about it in this blog post below.
Also, read this article by Matthew Flannagan:
The issue of whether God is a moral monster is only an accusation that many atheists make in opposition to the Gospel message. It is illogical for a fallen creation to accuse the creator of impropriety when it is their own sinful desires and broken souls that drive them out of the good. The accusation is made out of ignorance and confusion as to what is morally sound and right in the first place. If God is real, God does not kill anyone but moves them to another location on either side of judgment. Only man can murder a man.

