The question of how religions have developed is one that has been thought through for as long as people have been questioning religion. Why do religions seem to develop in similar patterns and support similar social structures? As of now, the best hypothesis is that religions developed out of our naturally formed social structure. It developed as a meme to explain the various occurances of the natural world.
The human mind is geared towards seeing patterns as a survival technique. A good example of this is that it allowed our early ancestors to pick out the panther from the background visual 'noise' of tall grass and thus get away before becoming someone else's lunch. This reinforced the pattern seeking tendency and it began to be applied everywhere. This pattern defining 'software' was applied especially towards unknown events such as natural disasters, death, disease, social structure, and any other natural phenomenons they could not explain or understand. Religion reinforced a hierarchical social system that was useful as populations grew in number. It also out competed opposing belief systems through normal memetic evolution)
Many characteristics of religion can be directly traced to how our early ancestors naturally formed social groups as populations increase. Observer any small group of humans and there generally will be no clear leaders. People will take on roles based on skill and chores are passed around on a basis of need and ability and not through command from a central authority
This can be seen whenever we observe any small surviving tribes of humans, we see that the population generally does not exceeds approximately 150 individuals. In fact if the population increases, the tribe will splinter, a section moving off to live elsewhere. In these limited population groups, every person is required to stockpile the necessary supplies to sustain the group. Thus every person is of equal standing to everyone else for survivals sake. The superstitions and religions that are held by these groups mirror this as they are invariably polytheistic with mostly equal power between the various deities. Any variation is based solely on the importance of the role that the individual deity has (the deity for fertility will be more important then the deity for something more obscure like the night sky). To further support the idea of 150 as a limiting number we can look to recent developments in Neuroscience. Here, studies and experiments on how the brain stores information has shown that the region of the human brain responsible for remembering individual faces has a limit on average around 150. Thus giving more evidence that humans initially evolved to be in communal groups no larger then this size.
But if we increase the number past the 150 mark, we find that there are more then enough people to gather food and other resources, creating even a stockpile. Suddenly we find individuals who actually have some free time away from general hunting and gathering. This extra time allows individuals to become specialists. Such specialists would include artisans, storytellers/historians, dedicated child rearing groups and much more. Each of which creates greater efficiency and allowing for more specialization.
As these independent skill groups develop another task oriented group naturally arises through emergence, this is the governing class. A group who starts by acting as a central processing to allow the burgeoning society to run more smoothly and effectively. This development of this new class adds an extra boost to the rate of development within the other individual skill classes as well as streamlining food production and availability, thus reinforcing its own existance.
This process is actually quite similar to the emergence that is seen in nerve tissues. As neural nets become more complex, densely packed regions of nerve tissue develop to allow for processing of the now expanding regions of complex nerve nets. These clusters are known as ganglions, and as evolution presses forward they too begin to arrange themselves into distinct control systems. These control systems start out as multiple ganglions converging into a single structure. A structure that eventually will become the central nervous system.
Just like in the case of nerve tissue developing complex systems, societies develop a ruling group that will become more influential as the population increases. With more people comes the need for strong central authority. This is then reflected in the belief systems held by the society. Before the population explosion there was an anarchic-commune of individuals with equal purpose. There was also a general equality in their religious beliefs. But as the population increase and one group of humans becomes more influential over the others, so too does one group of deities become more influential.
This places even more power and influence in the hands of the governing body and often allows for a schism. A split between the classes that controls the daily functions within the community and the group that keeps track of the beliefs.
The governance side dictates what is to be done within the community and the clergy keeps up the superstitions and beliefs that have developed, often forming a belief system where the governing body is in place at the will of the deities, or even that the head of the governing body is a deity or otherwise connected to them in some way. By doing this, they solidify the governing bodies place in society as the head of society instead of just a managerial system. This symbiosis allows for both groups to raise in power.
This leaves us with a belief system that enforces the status quo, explains away natural phenomenons as well as keeping the people in line. Looking at it from this angle it seems completely natural for such a system to form. Therefore religion seems to be nothing more then an evolutionary process to allow for survival under new conditions.