Good question, and one that I don't have a good answer for. I suspect that there is no single answer, that the varies from culture to culture, from religion to religion, and naturally for individual to individual.
One problem that we have in discussing religion is that our mental model is overwhelmingly based on the one (and rarely two) religions we're familiar with: in the West, Christianity or Judaism. But while popular, the great monotheistic religion of the desert (judeo-christian-islam) is only one religion out of many.
At Dangerous Intersection, Erich Vieth warns against accepting uncritically simple explanations for religion that are based on stereotypes or outright falsehoods. For example:
The claim: Religion allays anxiety
Why it’s not true: It generates as much anxiety as it allays: vengeful ghosts, nasty spirits and aggressive gods are as common as protective deities.