Actually there is a book by the name "When Bad Things Happen to Good People." No one here has read it. Of course, we don't need to, because we already know why:
There is no such thing as Justice
It is an illusion. A myth. A fairy tale. Life really isn't fair. The question is, why do you think it's supposed to be? Who started that idea? Job? The people who tried to put a good face on beating people up by inventing the Queensbury Rules? We don't know.
Justice sounds like a good idea because it sort of equalizes the pain. I get hurt, so you get hurt in return. Well there's more ocean than land, more roaches than roach motels, and more salesmen than prophets. Things just aren't meant to be equal. Suffering and happiness are not weights in some cosmic Martha Stewart food scale, their relative proportion is completely unpredictable, just get over it.
Here's the deal. Tragedy may be unequal, but it isn't random. Yes, there is a meaning, we're giving a bit away early here. Bad things usually happen to forcefully slap us out of whatever stupor we are in at the time. We are supposed to start questioning our beliefs. We are supposed to figure out what is and what is not important to us. People usually don't change unless they feel sufficient pain to overcome their natural resistance to change. Change takes energy. Nothing energizes like tragedy. What suffering is usually supposed to encourage us to do is figure out how to avoid suffering in the future. Find out what happy people do and imitate them. This is not rocket science.
If tragedy seems random and cruel now, it isn't. You're just not wanting to look at the facts. What facts those are exactly will be addressed in the Meaning of Life Part II.
Of course, if people don't get the hint and continue to imitate deer staring into the headlights of destiny, well, that's their lookout. Do not get mad at God/the universe/insert your cosmic principle here. Do what you're supposed to do, pick your ass up off the ground and try again. Nobody likes a crybaby.
You can't get out of it by going limp and giving up. That usually makes it worse. Athletes must tolerate a certain level of pain to reach their goals. You are no different.
As for the injustice of loved ones getting killed, etc., that has its own purpose. Don't ask unanswerable questions about other people; you've got enough to worry about with your own situation. If you get tragically killed, then you'll understand. Until then, forget it.
We have been criticized about the callous nature of this page. For people who have recently lost family members, etc., this little diatribe can sting. However, the message is still true even for them. Life is very unfair, but like chemotherapy, it does the job.