The easiest concept to understand from an evolutionary perspective is parental investment. Fitness is defined as the ability to produce viable offspring, but this entails more than just surviving long enough to procreate. Once the offspring are born, they must in most cases be protected by one or both parents: for example, a father may go off to hunt while the mother protects her young. If the parents fail to do this, their offspring will die and their genes won't be passed on. Thus, natural selection molds the behavior of many species to form a powerful parent-child bond.
What about cases where the genetic relationship is less pronounced? For example, why would a worker bee care about building the hive if it doesn't get to procreate? Why would a prairie dog sound an alarm to warn its siblings of an approaching predator if this could cause it to be eaten? Kin selection provides the answer. Suppose animal A has a gene that causes it to help related animal B, even if doing so reduces A's reproductive fitness. Because B's genes are similar to A's, B is also likely to have the gene that caused A to do this. Since A has made B more likely to survive and reproduce, A's gene is more likely to be passed on indirectly through B.
Among those species capable of complex cognition, a wide range of cooperative group behaviors are possible. For example, social predators hunt in packs: bottlenose dolphins will surround a school of fish, force it toward the surface, and take turns eating from it. Some dolphin groups off the coast of Africa even form alliances with fishermen, driving fish into the nets onshore in exchange for part of the catch. Sperm whales will defend themselves by creating a flower formation: vulnerable juveniles are protected in the center, surrounded by a circle of adults who face inward to create a barrier of powerful tails along the perimeter. And perhaps most touchingly, when one odontocete is near death, the others in its group will lift it to the surface to breathe.
We're already well on our way to explaining the moral sense we all share today. One additional idea to consider is that sufficiently advanced social creatures eventually form a culture. Individuals in such societies—and humans especially—are taught to hold certain values and beliefs. We learn them from our parents, from our friends, from our government and media, and even from complete strangers. These cultural values are so heavily reinforced that they become a part of us; this is known as enculturation. This idea may sound a little ominous, but in itself it's neither good nor bad: enculturation simply is.
Along with other values, cultures have a strong tendency to promote moral systems, because they help maintain order and are generally beneficial to society as a whole. These moral systems build upon our hard-wired altruistic and cooperative tendencies. Religion is one common source of moral values, but morality need not be so formal and ritualized. For example, the people of Scandinavia are largely nonreligious, but they seem by any measure to be just as moral as people in religious countries.
These phenomena give us a reasonably detailed understanding of the origin of morality in humans and other animals. However, it's important to realize that by explaining the evolutionary and cultural origins of morality, I'm not trying to derive an ought from an is. While these concepts tell us why we are moral, they say nothing in themselves about why we should be moral, or what moral truth is from an objective standpoint (if such a thing exists). These questions are better suited to philosophers, and I hope to examine them in depth—but that's for another day.
(Aside: I learned much of this information from a course I took on animal cognition. Book learnin' really can come in handy!)