When humans first invented religion—yes, we invented it; hard to remember, I’m sure—it was mainly to explain the unexplainable. We didn’t have microscopes or telescopes or any scopes, so we made up gods who were much like we were—jealous and horny and angry, only with much more power—who were in charge of these things. Why did Cousin Leon get smallpox, why did the drought hit, why did the invaders take over the land? Easy—the gods made it all happen.
Since we can explain so much more today than we could back then—not everything, of course, but much more—we seem to have turned to using religion for two main things: political control and radical forgiveness.