A number of studies find that religious people are happier than non-religious ones. Yet a number of fundamental questions about that relationship remain unanswered. A critical one is the direction of causality: does religion make people happier or are happier people more likely to have faith in something that is beyond their control? We posit that the relationship between religion and wellbeing is mediated by factors ranging from intrinsic purpose, to its social aspects, to its role as an insurance mechanism for people who face great adversity. We explore a number of related questions, using world-wide data from the Gallup World Poll. As these data are cross-section data, we cannot establish causality; we do, however, explore: how or if the relationship between religion and wellbeing varies across the two distinct wellbeing dimensions (hedonic and evaluative); how social externalities mediate the relationship; how the relationship changes as countries and people within them become more prosperous and acquire greater means and agency; and how the relationship between religion and wellbeing varies depending on where respondents are in the wellbeing distribution. We find that the positive relation between religion and evaluative wellbeing is more important for respondents with lower levels of agency, while the positive relation with hedonic wellbeing holds across the board. The social dimension of religion is most important for the least social respondents, while the religiosity component of religion is most important for the happiest respondents, regardless of religious affiliation or service attendance. As such, it seems that the happiest are most likely to seek social purpose in religion, the poorest are most likely to seek social insurance in religion, and the least social are the most likely to seek social time in religion.