I haven’t read much lately on evolutionary psychology or game theory, but enjoyed reading this talk by Karl Sigmund on Edge.org. Those who have followed this area even casually know that researchers have offered compelling reasons to think that diverse impulses such as generosity, altruism, cooperation, forgiveness, a sense of fairness, care for reputation and a desire to punish defectors are all grounded in natural selection. The combination of enlightened self-interest and our development as inherently social animals provided the basis for these impulses, which formed the backdrop for the later cultural evolution of moral codes and precepts in oral and written form.
Now, many have written eloquently on the topic of having why it is possible to have morality without religion. See for example this post from AnalPhilosopher. I think it seals the arguments to also note that morality predates religion (unless you are a “young-earth” creationist!)
Many are now studying the origins of religion itself from an evolutionary standpoint, but my impression is that this is a complex subject and there is no consensus yet on key points. However, it is pretty easy to speculate on the advantageous roles religion could have played in strengthening a pre-existing moral system among a social group (it seems obvious to anyone who is a parent): Religion adds both putative authority and a promise of punishment/reward to moral instructions, thereby giving them some extra oomph.