Religion, as we know it today, and can look back on its history, has served a multitude of functions for the human race.
That is, systems that actually make it harder for a culture to survive biologically (i.e. celibacy) will tend to vanish due to a lack of believers, and ones that aid in their adherents biological survival (i.e. certain dietary restrictions might come to mind) will flourish. There is also the case of biologically "neutral" systems of belief, which will only be sorted for or against based on how readily they are accepted - that is, how well they "fit" the psychological and emotional environment of the individuals in that culture.
These are the common functions of traditional, superstitious religious traditions:
1. Answer unanswerable questions posed by scared, imaginative apes in the night.
In the dawn of man, so little was known with any degree of certainty, that the stories and myths of early religions were able to step into the void and provide "answers." The questions vary, but they are the big ones - where do we come from? Where do we go when we die (for we apes are the animals that know they must die, more surely than any other)? What do our lives "mean?" Where do babies, food, weather, etc., come from? What is fire? What is rain? And so on and so forth.
While science will never answer all of these questions, it certainly has worked out a lot of the details of how our universe functions. This has rendered obsolete many of the answers provided by what have become our "holy books." What is left are questions about meaning, more than anything, and I do not think that "to blindly worship and serve your god" is a particularly insightful kind of meaning to inject into life. Perhaps, once upon a time, when the gods were ascribed the power of creation, and were the explanation behind virtually all natural phenomena, this made sense - who would not, indeed, worship the source(s) of lightning, thunder, the sun, babies, food, love, and ascribe to it (them) the basis of all life's meaning?
2. Provide social order, control, stability.
From their earliest days, by dint of the visionary spiritual power expressed by their founders and leaders, religions were probably the first organizations of social order and control that rose above the extended family, or tribe. By assigning meaning and value to events both within and beyond the comprehension of the populace, their leaders obtained a special place of unassailable power in the primitive cultures of mankind.
This function is now obsolete, with the development of humanist thought and the concept of sovereign power being vested with the people, to be temporarily carried out by their chosen representatives, rather than a predetermined oligarchy.
3. Teach the structure which can provide a sense of transcendence.
Interestingly enough, this is probably the one valid and true work a religious tradition can still provide. To create in the young a sense of mystery which can be enhanced to experience and some understanding of transcendent states. Sadly, even though many religions do some small work in this area, they tend ot load down their adherents with so much theological baggage (their obsolete, unnecessary stories and myths) that even when such states are obtained, they are not clearly understood or even appreciated as a function of Man and not God.
This then leads people, having experienced perhaps incredible things as a result of some of the teachings of their religions, to accept the rest of the teachings. These teachings have some unfortunate components in some religions - particularly, but certainly not limited to, the religions of Abraham that have risen in the Middle East. Teachings that lead to violence and hatred, due to no more than a difference of mythology between religious traditions.
Granted, many of these murderous traditions date to times when there were other reasons to annihilate the other peoples that a tribe encountered - reasons that have been supplanted to some extent by the modern, secular, nation-state. Things like water rights, territorial sovereignty, and systems of law and justice, which once were the exclusive province of religion, are now dealt with, for better or for worse, by non-mystics, via politics, statesmanship, diplomacy, and of course, the old standby: war. War - not again!
If religions are to provide any useful function in this day and the future to come, it strikes me that they are two-fold:
1. Teaching the methods and understanding of transcendence - without the burden of dogmatic requirements that beautiful myths and allegories about life be taken as actual historical (or predictive) truth.
2. Acting as a force for cooperative moral examination by the people of their secular governments. This is not to say that morality is the province or responsibility of religion. It is to say, that here is a structure that is very appropriate for the organized efforts of moral mankind to restrict and judge the actions of their political leaders and representatives and limit the inevitable abuse of their vested powers.