Life is unfair. When you outlive your child, when a family member dies suddenly, when your grandparent has a mental disease, you think why? Life is filled with random uncontrollable variables. Religion is there to get you through those times when life seems pointless, when you feel like you have no purpose. (P.S I am an atheist)
There once was a time when all people believed in God and the church ruled. This time was called the Dark Ages. Religion does three things quite effectively: Divides people, Controls people, Deludes people. If my life is good then I do not need god. On the other hand, if it is bad then what is the use of god?