This individual then meets up with another bunch of people. He finds that his life becomes a lot easier if he can get their help to search and hunt for food, make cloths, build shelter, and fight with him against predatory animals. He realises that with specialisation of skills, the talent and economies of scale can be exploited to greater benefit. Thus with the interest of self-preservation he joins a community.
One day this person murders another man, steals the victim's food, takes over the victim's cave and lies with his woman. The others in the community realise that if these kinds of acts are encouraged people will stop doing their own hunting and their own work. The society will crumble. They see the danger that is inherent in allowing such acts to continue and will enact laws to prevent it. The act of killing and stealing becomes immoral as it is so conditioned by punishment. This punishment is not just physical but also psychological (seclusion, derision, enmity). Soon people instinctually realise that it is bad to kill and steal. They feel guilty. They have added that to their social and individual conscience.
As the society becomes more advanced they tried to explain what is going on around them. They envisaged great powerful beings striking down with lightning, crying down the rain, roaring out thunder, asking plants to grow, flowers to bloom and fruits to ripen. They began to explain away in similar fashion, the phenomenon of birth and death, dark and light, of the sky, stars, earth, rivers and the seas. Some societies had gods for every natural occurrence they couldn’t explain.
Leaders of these small societies gradually realised the advantage in imprinting the moral codes in religions, the advantage of having these great unseen yet immensely powerful beings in charge of what is right and wrong. They realised that the community will more readily accept their rules if they believed them to be inspired by the Divine.
A few thousand years forward the community has developed into a civilisation. The religion has changed to meet the needs of this society. As our scientific knowledge increases and we continue to learn about the nature of the Universe, many of these gods become redundant.
But the moral codes that were tied to the religion at its birth are still there. Many people still believe in Divine justice, and many feel that they would be judged in their afterlives for sins they commit.
A significant detail of the way in which morals have evolved is that specific standards change from society to society and time to time. For example merely a century or so ago nationalism was a virtue. Pride in your race and the desire to protect it was a virtue. This attitude was necessary for society to flourish in the face of external threats.
With technological improvements in areas of communication and transport, and the benefits of global trade, most of us have come to believe that nationalism is in fact the cause of wasteful wars and that it is destructive to the welfare of the community. In most advanced nations, nationalism is now considered a vice.
No less than three centuries ago, it was sin to question the Divine Authority of our Kings. It was sin to rebel against the noble blooded aristocracy. This was only natural in societies where strong rulers are needed to govern a nation surrounded by enemies. This loyalty and unquestioning obedience is still encouraged in our armed forces. However in much of the rest of society, where we conduct commerce instead of war, we have begun to recognise equality as a virtue.
Yet it would be a mistake to arrive at the conclusion of all morals are strictly relativistic. It could very well be that moral codes throughout human history are derivative of some fundamental source, whether it be Theistic, Pantheistic, Deistic or any of a multitude of possibilities.