When we think about God's actions, should we also even consider the butterfly effect as well? Not only do we not know exactly what will happen as a direct result of one action, we don't know what effects it will have 1000 or even 2000 years from now because of the chain of events that happen as a result? So when considering the entire universe and every particle in it, for every second that it exists, there is one best solution to any given problem that only God can know?
Much research has been undertaken when it comes to chaos theory. The theory that deals with how seemingly insignificant events can have enormous importance in the future. The butterfly effect is one such notion. A butterfly flapping its wings outside my window in North Carolina may set in motion certain events that 10 years from now will cause a Tsunami off the coast of Japan, for example.
The appeal is made to this notion by Christian philosophers who respond to the argument that God could not have morally sufficient reasons for allowing or causing certain things to happen. The appeal is made to point out the fact that we as finite human beings simply are not in a good position when it comes to saying God could not have morally sufficient reasons for doing something or allowing something.
Going back to the butterfly outside of my window. I, being finite in knowledge and perspective, simply have no way of knowing that a Tsunami would result as an effect of a series of causes and effects tracing back to the butterfly outside of my window. There is no way I could know that.
Likewise, when we look at the few instances in the OT where God commands something that initially makes us recoil, we simply are not in a position to say, "It is impossible that God could have morally sufficient reasons for commanding x." We are not privy to the knowledge of what would happen had x not been commanded. Nor are we privy to all of the knowledge that will happen after x is carried out.
But if we come to know God through personally experiencing Him and His love and His compassion and His concern for us, then we have that assurance that even though we may not understand why He allows or causes certain things to happen, we can trust Him because we personally know He has our best interest at heart.
Now with regards to whether or not God always does what is the best thing to do, I think it helpful to remember that what is "best" will be determined by God, not us. God will always do what He wills to do. But what He wills to do may not always be what he delights in or takes pleasure in doing.