In order for us to examine the function and benefit of a religious practice or belief, we must have some sort of ontological framework in which to examine the practice. It would be somewhat arrogant for us to assume that any one religion or view is correct and reject all others. We should only work from what we can logically ascertain to be true. To that end I propose to examine religious practice through the lenses of three hypothetical realities.
Hypothesis #1: God or gods exist external to and independent of our reality
In this hypothesis, there are one or more supernatural beings. This being or group of beings is capable of interacting with us as individuals and with the stuff or our reality at will, and this interaction is independent of what we consider to be natural laws. The key attributes of this hypothesis is the ability of deity to choose whether to act or not, and to choose how to act. When a miracle occurs it is because a deity chose to create the miracle.
It is tempting here to ascribe other qualities to our deity here, such as intelligence, benevolence and rationality but there isn't any basis for doing so. Even in this hypothesis we must set aside our preconceptions and consider that we may be considering one god of many; a rational god or a mad one; a benevolent god or malevolent or neither. If there are more than one god, then they may work together in harmony or they may be at cross purposes and in conflict. Intelligence may be overcome by emotion. Even if we are dealing with a single intelligent, rational and benevolent deity, we cannot presume that we are able to understand the rational purpose behind this deity's choices in interacting with us.
Hypothesis #2: There exists a natural phenomenon not currently understood but that can be accessed through religious practices
This view contemplates the idea that the anecdotal evidence commonly attributed to the actions of a god or group of gods is actually the effect of a natural process that is governed by natural laws that haven't been discovered or described yet. Here, the practice of a ritual in some way aligns something internal to the individual - or the individuals within the group participating in the ritual - with some external force or energy that is able to influence the events within our reality. Some individuals may be more able to align than others, or they stronger than others. There may be external influences that can aid in the alignment or that can dampen it. Finally, there may be practices that are more effective than others. When a seeming miracle occurs it is because of the alignment of natural forces directed by the religious persons involved.An extension of this hypothesis is the idea that all of the intelligences in the universe are a part of a much larger intelligence, which some call the "cosmic consciousness." This cosmic consciousness directs the events within the universe based on the input received from its component parts. In this sense we may be working with an intelligent entity, but this entity is constrained by the physical laws of our universe.
The important aspect of this hypothesis is that it is a natural phenomenon that is not independent of the laws of nature. If we can understand the laws that govern its operation we can predict the outcome of various ritual practices and develop techniques to make theses practices more effective.
This leads to an interesting observation about faith, which I will explore in more detail later, but for now it is sufficient to note that "faith" or the individual's belief or lack of belief may be deterministic of the effectiveness of a particular practice; and the corollary that the absence of faith in an outside observer may provide a dampening effect that reduces effectiveness.
Hypothesis #3: Neither gods nor unknown natural phenomenon exist, the supposed effects of religious practice are nothing more than coincidence, superstition, and faulty reasoning
This is the atheist view. At first glance, this hypothesis appears to contradict our working hypothesis that there is a reason for humans brains to be pre-wired to believe in the supernatural, but this isn't necessarily so. In this metaphysical framework it is entirely possible that the belief in the supernatural and the practice of religious ritual serves some internal purpose beneficial to the individual. It is possible that this is the actual spark of human creativity - the ability to conceive of things beyond what the senses tell us is real.
While this hypothesis cannot account for the mythological miracles such as the global flood or the parting of the red sea, it may account for the anecdotal healing miracles and the miracles of human achievement. Even if it doesn't, it still provides a reason for humans to believe in the fantastic constructs of the perceived supernatural.