The question is not "what role does religion fulfil", but rather, "if religion wasn't there, would things have been better?". Because, e.g. many recreational drugs ALSO provide values, hope, and guidance (on one hand), and some religions like Mormonism and Scientology also provide them, but apparently forbid leaving them (read about excommunicating in either) to the point that I find unacceptable in a society.
Disregarding the obstacle of definition of religion vs. e.g. cult vs. value system, my opinion would be, based on observing mostly-religious states vs. mostly-secular states (like Sweden and Norway), would be that value provided by religion is a net negative.
 if you insist, I will say that beleief X is a religion iff there's a government of a country with >10M residents that accepts it as a religion for the purpose of its law. Specific definition is immaterial - they will all coincide for 99% of the population, and will have essentially no effect in the grand scheme of things.
Be careful. I think the general consensus about these observations is that what's happening is that less stable and secure societies tend to make people more religious, rather than that religion tends to make societies less stable and secure.
I am not aware of this consensus, but it is entirely unrelated to my claim: The supposed benefits of religion are nil, because comparable countries that essentially eschew religion fare at least as well, and usually way better than those that do not.
I did not make any claim about the relation between stability and religion. Swedes and Norwegians, as nations, are the best educated, best nourished, among the healthiest, with virtually no crime compared to e.g. the US or Italy. What exactly are the positive benefits that you get from religion that you do not get without?
Observation: Various measures of societal health are correlated with lack of religion.
Explanation #1: Religion is bad for society.
Explanation #2: Bad society is good for religion.
Both explanations are at least somewhat plausible (religion is bad for society because believing falsehoods is morally corrosive, or because religions are full of ideas founded in old moral systems that we no longer endorse, or whatever; societal ill-health is good for religion because people in difficult situations will turn to anything that seems to offer comfort, or because when things are really hard the gods really do help, or whatever). In particular, the plausibility of explanation #2 means you can't just leap from the observation to explanation #1.
For the avoidance of doubt, I am not claiming any particular benefits for religion. I'm an uncompromising atheist myself. I just don't like plausible but unsound arguments, and "The Scandinavian countries are great places and also very irreligious, therefore religion isn't good for you" is, I think, a plausible but unsound argument: it could equally be that their irreligiousness is an effect, not a cause, of their education, good health, low crime, etc.
(On the other hand, "The Scandinavian countries are great places and also very irreligious, therefore religion isn't vital for a healthy society as some religious people claim it is" is a perfectly good argument, and one I've used myself.)
[EDITED to add, on the subject of that putative consensus: see e.g. http://edge.org/3rd_culture/paul07/paul07_index.html, a single article but one written by two of the biggest names in the field, Gregory Paul and Phil Zuckerman. "To put it starkly, the level of popular religion is not a spiritual matter, it is actually the result of social, political and especially economic conditions [...] Mass rejection of the gods invariably blossoms in the context of the equally distributed prosperity and education found in almost all 1st world democracies. [...] Mass faith prospers solely in the context of the comparatively primitive social, economic and educational disparities and poverty still characteristic of the 2nd and 3rd worlds and the US." I should perhaps emphasize that GP and PZ here are talking about the origins of large-scale popular religiosity; individuals' decisions are, well, more individual and it certainly isn't true that all religious people are that way because their messed-up societies make them look for supernatural aid.]
But I want to reiterate, that I only ever claimed "sum (religion benefits) <= 0", which I believe is equivalent to your statement that "religion isn't vital" (or rather, "religion isn't helpful"). At no way did I imply any other cause and effect relation other than the one implicit in this statement.
Does it help them climb out of poverty or does it only help them reassure themself the world is exactly right, their poor lives are okay, and everyone smarter than them should be stoned to death?
It seems to me that religions that prey on unstable, unsecure societies are especially nasty these days. Evolved to conquer poor societies and keep them that way!
I guess ultimately the world would be better without religion if you only consider the negatives, but if the world is better without religion then it's also better without alcohol, drugs, cars, love, internet, business...
Seriously... Do you forget what was responsible for spreading education so rapidly around the world (give you a hint, it wasn't atheists).
There are a number of religions that are founded in rationality, and large components of others that are pure rationality. Just because you don't believe in (a) G/god doesn't mean you aren't religious. Just because you believe in a G/god doesn't mean you are irrational.
Now, if you are saying 'religion' to mean 'societal construct' or something like that, well, that is a different ballgame. Though I don't think you mean that, so the above applies.
Bottom line, the major religions of the world demand someone to suspend rationality to believe. Otherwise the followers would not be followers.
And as for educated. Perhaps there isn't a conclusive study on the subject, but it is safe to say that the more educated you are, the less likely you are to be religious, particularly fundamental. http://en.wikipedia.org/wiki/Religiosity_and_intelligence
Yes, religion is by definition irrational. Humans generally aren't very rational beings. Love is irrational, it makes us do irrational things, but I'm sure we can agree, on the balance, love is a good thing. Thus dismissing religion on irrationality grounds is not very meaningful.
I also didn't say we should dismiss religion because it is irrational, I said people who were religious were irrational. I believe that still stands.
If anyone asked, I would say we should dismiss religion because it is harmful. Harmful to our stability, harmful to our advancement, harmful to the people that follow it and harmful to the people stuck in it against their will (either country, family or society). Today the negatives of religion far outweigh any good it can do. There was a time and place for religion, but we have outgrown it.
The Middle East isn't solely a religious conflict, it's very much an ethnic one as well. Oppressive countries are oppressive, they're not liberal countries that just happened to read in a book that they should kill and maim those that worship in the wrong way. Closely knit groups (families, societies) are going to sanction deviators regardless of religion.
> And as for educated. Perhaps there isn't a conclusive study on the subject, but it is safe to say that the more educated you are, the less likely you are to be religious, particularly fundamental. http://en.wikipedia.org/wiki/Religiosity_and_intelligence
Correlation or causation? I don't really have time to read through all the studies, but St Thomas Aquinas is a good counter example of that premise, very analytical, very religious...
Should we now declare that, given that Newton, Galileo and Socrates likely had lice (the blood-sucking kind) for some part of their lives, we should consider lice a vital part of our cultural heritage and that any modern scientist should get some?
And still they think of themselves as an example for everyone to live up to.