You're basically saying "God can do whatever he wants because he's always righteous"
So I guess he was righteous when he gave people instructions on buying, owning and beating slaves too right?
Or when he told his people to take literal minors as wives and sex slaves after having murdered their fathers, brothers, and sometimes mothers, because they were quote on quote "wicked people"?
Get help.