Well I know you asked for a theist perspective but I'm gonna provide an atheist conjecture.
It seems to me like religions usually explain things like why the universe exists, why death exists, why we're able to stand tall at all and ask questions like "what is my purpose," "what happens to me when I die," "why is anything there at all?"
All of these are legitimate questions, and I think religion offers confident (if bogus) answers, and that's so very comforting to many people who want to see their relatives again, etc.
Not all religions deal with all of these questions but many deal with at least a few of them, some of them deal with all of them.
Religions typically tell us that we don't have to worry about death because in some sense we live forever -- which is the ultimate sentient being's dream; to fail to stop existing.
Religions answer the problem of justice by saying that evildoers who escape justice in this life will face punishment in some "next" life -- another dream of sentients.
Religions answer the problem of suffering by saying that suffering is temporary and that we'll experience inexplicable joy in the "next" life -- another dream of sentients.
It turns out that pretty much anything that we "want" to be true, as sentient beings, somehow IS true in religion. That's interesting to me, and the definition of "wishful thinking."
To answer the original question, it seems from my subjective opinion that religions had half to do with solving these questions about existence and death and then half to do with explaining why things exist and how things that exist work -- such as explaining lightning, rainbows, the diversity of life, and so on.
Religions persist because there are always believers readily available (or so it seems to me). Even people who believe that their religion is the "one true religion" have to admit that people are so gullible that they'll believe just about anyone that's convincing enough; there are examples throughout history such as Jesus, Mohammed, Joseph Smith, L. Ron Hubbard, the guy that wrote Oaspe (or however you spell it), and so on.
Sometimes religions get lucky and someone really famous and powerful adopts the religion either because they truly got suckered into it or because they think it could help their position (Constantine, Tom Cruise, etc.)
Fact is that nearly everyone's religion is determined by their culture, parents, and people around them -- religion typically spreads through cultural diffusion with rare exceptions.
You know what else spreads through cultural diffusion? Fashion.