The way God runs the world is not always easy to fathom. So often it just doesn’t seem fair.
Yehudah HaLevi offers an answer in his Kuzari: the creation as a whole is good, and everyone can see it. So any particular Divine act must be part of an overall pattern of good, and if we can not see the goodness in a specific moment it may be because our vision is too limited.
Other philosophers have their own approach; indeed every philosopher has to tackle the question sooner or later, and the range of philosophical explanations is vast.
But Rav Soloveitchik makes an important distinction between moments that can be approached philosophically and moments that can’t.
When a real human being is in pain it does not help to start with philosophical analyses of the problem of evil. At that moment it is all too cold, too analytical, too academic.
Someone has died: is that a time to say dispassionately that death is a universal human experience and sooner or later everyone must die?
Try talking like that and you’ll deserve the rebuke, “Yes, yes, but why was it my mother (or father or spouse or sibling or child) that God had to take, and why did it have to happen this way, and why did it have to happen now?”
There is a time for philosophy, but there is also a time for quiet, sympathetic companionship – there is a time for talking, and a time simply for being there.