It is important to understand the context of these acts attributed to God or at least seemingly approved by God.
First off and in reagrds to the stipulations for Israel ( the many laws of thr Torah):
Israel was being prepared and made into a theocratic nation, a nation to be pure and blameless under God BUT a nation that had been enslaved for generations and had very little regard for what was "sacred" and had to be made to "stand apart" from the other nations.
The Laws of the OT were designed for that and some of them, as EZkiel pointed out, were "bad laws" for a reason.
With the severe infulence of the bordering nations the Laws became as severe and it is also important to note they were causal laws ( If a person does...).
IN regards to the various acts that WE deem immoral or worng based on OUR understanding, I freely admit that many are quite bothersome ro say the very least.
But context does help us at times and an example is the story of Elisha:
Kill Brats From there Elisha went up to Bethel. While he was on his way, some small boys came out of the city and jeered at him. "Go up baldhead," they shouted, "go up baldhead!" The prophet turned and saw them, and he cursed them in the name of the Lord. Then two shebears came out of the woods and tore forty two of the children to pieces. (2 Kings 2:23-24 NAB
ON the surface it seems that Elish commanded wild bears to kill children that called him "baldy", BUT is that what happened?
Elisha had just purified the waters of Jericho and was on his way to Bethel when these "kids" came and started to harrass Him ( the same guy that just purfifed their water), so Elisha cursed them and bears attacked and, here is a crucial element, killed at least 42 of them:
23 Then he went up from there to Bethel; and as he was going up by the way, young lads came out from the city and (AB) mocked him and said to him, “Go up, you baldhead; go up, you baldhead!” 24 When he looked behind him and saw them, he (AC) cursed them in the name of the Lord . Then two female bears came out of the woods and tore up forty-two lads of their number.
So, we know that AT LEAST 42 "hooligans" were harrassing a man that had just purified the waters.
Now, I don't know about you guys but I think that AT LEAST 42 trouble makers seems like a gang of thugs, yes?