For any given action that God might take, or might not take, there is one and only one "best" action to take (even if that is inaction).
God cannot do anything but the best action because it is his nature to be good and perfect, and anything less than the "best" action would be less good and less perfect.
Am I still right so far?
Bear in mind that when we think of "best course of action for God to take", we have to keep in mind that this is going to take into account God's purposes for whatever specific action that He is undertaking which itself will find its part in God's overarching plan for humanity.
Let us take Amalek for instance. The Bible gives us a reason as to why God ordered the Amalekites to be destroyed.
What did Amalek and his people do? Centuries earlier "he attacked you on the way when you were faint and weary, and cut off your tail, those who were lagging behind you, and he did not fear God...... You shall blot out the memory of Amalek from under heaven; you shall not forget."
The verdict to Saul when given the command centuries later: "Thus says the Lord of hosts, ‘I have noted what Amalek did to Israel in opposing them on the way when they came up out of Egypt. Now go and strike Amalek and devote to destruction all that they have."
God's immediate purpose is clear. The Amalekites were to be destroyed because they preyed upon helpless people and they did not fear God. God waited centuries before executing judgment on them.
This would find its place in God's overarching plan for humanity in that it would serve to strengthen the nation of Israel from a continually antagonistic neighbor which sought to only do them harm. The Messiah would eventually come from David's descendants who, had the Amalekites gone unchecked, may very well have been overtaken and destroyed.
The preservation of the line of the Messiah, the Savior of the world, and the eradication of nomadic, ruthless, no good bandits who preyed upon helpless and weak people and who did not fear God were God's purposes that we know of in ordering the destruction. The destruction He ordered was the course of action He saw fit to order in accomplishing at least the aforementioned.
He did all of this while not abrogating their capacity to continue to be free moral agents.