In my university days I would often have philosophical debates with religious friends. One of them once tried to convince that, if there was no God, there would be no reason to "be good" - that the root of morality had to be spiritual in nature.
As reasons for believing in Gods go, that one seems to be a particularly bad one. Most atheists don't go around raping and murdering people.
My friend presented me with a thought experiment. "Suppose you could kill someone you didn't like, in such a way that it would be provably impossible for anyone to find out it was you - would you do it? A Christian wouldn't, because it's against the wish of God, but an atheist would have no such compunction." Well, first of all it's ridiculous to speculate about an impossible hypothetical situation - no matter what form the proof took, it's impossible to be sure that no mistake was made and that you could never be found out, so as far as you can tell there is always an element of risk. Also, my friend was effectively arguing that the only reason he wouldn't kill is because someone (God, if no-one else) would always find out and dole out punishment. Avoiding a potential punishment seems to me to be the least moral reason for avoiding murdering people - the golden rule is a much better one.
My friend could not conceive of how a sense of morality could have arisen in the human race by evolution alone. But after a small amount of though I realized that there are many evolutionary advantages to helping the other members of your community. If you help your community, the community as a whole is strengthened. The other members of this community are likely to share more of your DNA than members of rival communities. So any advantage to your community improves your DNA's chance of surviving and reproducing. Thus, communities with a sense of morality will tend to be favored by the evolutionary process over communities with no sense of morality.
It isn't just individual survival and reproduction that drive evolution - groups of related individuals exhibit all prerequisites for evolution as well (variation in hereditary characteristics producing survival and reproduction advantages) so social behavior can evolve just as well as body shape.
In order to evolve, social behavior does not have to be encoded in DNA. Ideas can (and do) evolve and propagate just as genes do. The human mind provides an environment that is fertile for memes to breed and evolve. This is good, as speeding memetic evolution gives a survival advantage for our species (arguably, it the one thing that has allowed us to be so spectacularly more successful in control and adaptation than any other).
But just as we apparently have some "junk DNA" in our chromosomes which is reproduced faithfully but doesn't actually do anything useful, we may have accumulated some "junk memes" as well. Perhaps these aided our survivability in the past but now serve no useful purpose. I'll leave you to speculate as to what these memes may be.