E.O Wilson had an interesting answer to this question, he documented it in "On Human Nature".
http://www.amazon.com/On-Human-Natu...id=1359450297&sr=8-1&keywords=On+Human+nature
Religion serves fundamental human needs in the following respects and it often does so more efficiently than alternative institutions.
1. It provides its practitioners with powerful socio-cultural incentives to preserve group cohesion and solidarity.
2. On a fundamental level, it is an expression of optimism about the destiny of mankind because most religions strongly emphasize the premise that their adherents will reap the benefits of eternal joy. In most cases, optimism enhances the quality of life of most people who display this attitude in abundance. (See Martin Seligman's Learned Optimism,
http://www.amazon.com/Learned-Optim...d=1359450457&sr=1-1&keywords=Learned+Optimism)
3. Religion provides a comprehensive ethical framework, the basis for conventional morality and even etiquette. Although certain modernized, well-developed societies formally disavowed religion, their collective consciousness has been influenced by doctrines of religious ethics. Had religion not existed at all, it would have been questionable that these societies could have become socially, politically and culturally sophisticated enough to preserve order without any explicit reference to a religious dogma.
4. The elites of most societies have a vested interest in preserving the ethos of religiosity because most creeds defend a horizontal social order that calls for the presence of a hierarchical power-structure and centralized authority. As a general rule, when the elites abolish the institutions of one religion, they swiftly replace them with institutions representing a different creed that serves the same political purpose. Consider how the deeply religious Russian society quickly accepted Marxism-Leninism as its de-facto state religion.