That's something I struggled with for a long time. Why do bad things happen to good people?
If a child dies in an accident or some fatal disease, their life is ended early, and they had no say in the matter. It's easy to be angry and bitter, and to blame God for allowing it to happen. The pain is real, the loss is real.
But I found out (and it took me years to find out) God's wisdom is greater than mine, and to trust in Him. I also learned if some tragedy happens in your life, you either become bitter over what happened to you, or you become compassionate for someone who suffered the same as you.
Things happen for a reason. Sometimes we may never understand why, so the best I can do is trust Him.