I've wondered the same thing.. God, or a primordial being is perfect in every way so even if something seems out of the ordinary or mindless to us, I still think it's all part of a certain plan, even if it takes a few years or even centruries for us to realize.
Bear with me for a moment here, I'll give an example. Let's say that hypothetically, there is an illness that is not well known, maybe due to lack of funds for research or simply ignorance of the masses. Hundreds of people die yearly (rare) from this illness as it ravages the organism and literally anyone can succumb to it. One day a famous or extremely kind person dies, one that had a family, lead a just and good life commited to the welfare of others around said human. Someone who had absolutely no "right" to die, implying that people die for a reason.
When he/she dies, some people will naturally become infuriated and ask themselves' "why? What has the power to take away someones life who didn't deserve to die? I want nothing to do with a "god" that acts like this." A possibility (one that happans often) is that the awareness of this illness becomes more and more embedded into the knowledge of the general public. Soon, maybe wealthy people contribute their wealh into the research for a cure. Later on if all goes well (this could take years, decades or even centuries) humans find a way to prevent, or perhaps slow the rate at whick someone dies when racaged by such an illness.
Therefore, out of that "injust and undeserving death" thousands, if not millions of people in the future have a chance to fight against this hypothetical illness, all thanks to the event that killed the famous person.
This is an extremely arbitrary notion, but I hope I was able to explain it in a understandble way.