For most of us, it's just a matter of being at the wrong place at the wrong time - period.
Different religions answer this in different ways.
Karma says no bad deed goes unpunished and no good deed goes unrewarded. Well, I've seen a lot of people live their lives in horrible ways that have consequences on others so I'm not a believer in this. I do think this is true but not in the sense that it's intended. God will punish those and reward those but it's not in this life.
The Buddhist give up the notion on self. Pain results from our desires and our wants. I personally have a hard time grappling with this. So if I have no desire then I will feel no pain. So if I create an example out of this. I just desire my special needs child to have friends - and his autism makes it hard to do so. And when I see him upset because of social situation my sadness is because of my desire to have friends. This makes no sense either. We were created to be with people and my desire is to have him experience this in a good way.
And then there is Christianity that clearly states there will be troubles in this world. Yup, there are. For me, I have to look to the Bible and have faith. I see over and over again where God is faithful. And so by studying this I am able to answer - Yes, Life is NOT fair. But God always makes it right. For me it's just faith. I don't have to have all the answers - life is to big to have all the answers. And so I will continue to place my faith in Jesus Christ and the salvation and eternal life that he has promised.
Back to why Life is unfair. For me, I think it's simple. We live in a fallen world where there are evil forces acting upon us that we can't see. I look to the Bible to prove this. Jesus was tempted by Satan. Yes, Satan has an army helping here on earth because this is his dominion. But not for long - God has his army and it is way bigger than Satan's and someday, Satan will be banished from this earth and it will be God's dominion (the books of Daniel and Isaiah are loaded with goodies in case you are interested in reading more).
But rejoice. Don't be down and upset that life is indeed unfair and that you can't make it right. You don't have to. Jesus came so that you don't have to!