And [God] said, “I Myself will make all My goodness pass before you, and will proclaim the name of the Lord before you; and I will be gracious to whom I will be gracious, and will show compassion on whom I will show compassion.” – Exodus 33:19

On Mt. Sinai, God declared to Moses a profound and foundational truth that permeates all of Scripture, the doctrine of God’s sovereign choice.
Our God, the one true God, is volitional. He has a will, and He exercises it in accordance with His holy character and attributes. Since our God may be known by His actions, we see that He is (among many things) righteous, holy, and transcendent as well as loving, gracious, and merciful. Being infinite by nature, our Creator is capable of resolving any apparent paradox which may confound our finite minds.
On the other hand, in possession of a Holy Spirit-guided understanding, a Christ-follower can with some assurance discern how God might act in a particular set of circumstances or situation for He is (as mentioned above) consistently “good.” We know that our God will never act in a manner that is inconsistent with His holiness.
Whatever God’s decision, it is always righteous, even when it is difficult to understand. This, too, is grace.
When you go through a trial, the sovereignty of God is the pillow upon which you lay your head. – Charles Spurgeon