Good is defined by whether there is a rational reason why it is good. God gives rational justified reasons for his actions.
OK, so you subscribe to natural law-or maybe you just do when divine command theory inevitably starts popping out absurdities. Lets have a look at one of your favourite genocides from the bible, the great flood and the stated reason for it.
6:13 And God said unto Noah, The end of all flesh is come before me; for the earth is filled with violence through them; and, behold, I will destroy them with the earth.
Note he's not just talking about humans, he's talking about bunny rabbits, cows, molluscs and let's not forget all those unborn children (violent, violent unborn children). Because there are a few violent douches douching around Yahweh will violently douche on everything but Noah's floating zoo.
Yes he gives a reason, no it is not rational or justified. It makes no sense to combat the existence of violence with greater violence that does more lasting harm.
In Genesis 32:25 God enters a wrestling match with Jacob and loses so he uses magic to break his leg. Now you could argue in a sense that's rational, if all you want to do is show you can win but it's not justified - wrestling is matching ability and skill and cheating just shows you're a dirty, rotten cheater. In Exodus 9:16 God tells the pharaoh that he put him there just to show him his power. Rational? You have literally infinite power and resources, is raising up a dynasty just to bring it down the most rational way to go about this? Why not just do the Jesus trick and pop out some Merlot and mudskipper from thin air? Justified? Come on, set aside all the plagues, misery, dismembered cattle, fermenting frogs and dying children and just make Moses pharaoh-get the other guy to be chamberlain of the royal stool or something!
Unless you're defaulting back to divine command theory and calling it rational and justified because it comes from the creator and therefore in must be, blah blah blah it isn't possible to call all of the actions of a notoriously jealous and wrathful deity both justified and rational. Unless of course you're just here to troll, and you enjoying defending perversity merely to annoy. The thought has crossed my mind...