Formal religion , meanwhile , is supposed to have appeared only after agriculture produced such hierarchical social relations as required a cosmic backstory to keep them going and supplied a template for the power relationship between gods and mortals .