There never was such a thing as absolute justice, but only agreements made in mutual dealings among men in whatever places at various times providing against the infliction or suffering of harm.”
Morality is a property of the society. The accepted version of morality that is in general use in a society is normally instilled to the individual members of the society through education both at home and in institutions like day-care and school.
However, in modern societies the idea of accepted behavior (read: morality) is gained most of all through literature, television, movies and other media. Every single human society on earth needs to have a rulebook over allowed and not allowed behavior. We often call this necessary and mostly beneficial social need with the name of "morality".
We also often are under an illusion that it comes from us and not from the needs of the society. This is so because this illusion has been built with great vigor by very many people in the past, and this idea is now commonly believed.
The basis for all morality in individual members of the society is the fear of being caught, as Epicurus already noted 2400 years ago. According to Epicurus a person can also strive for tranquility and happiness only when he does not even secretly do things that society forbids.
Epicurus also noted that unjust laws need to be changed if and when the needs of the society do change. Unjust and outdated laws just cannot expected to be followed in the long run. According to recent research all humans share certain basic instinct for fairness and justice. Also, the other great apes have such universal traits. They are simply products of evolution.
Having these feelings of justice and fairness have given a clear evolutionary edge to those groups of humans who have shared things more fairly with others and have really cared for other members of the group.
The universal feeling of fairness and justice are, however, often suppressed by society. This needs to happen, for example, if a society is based on unfair and unjust division of wealth.
Religions have been often important tools in keeping up class privilege in the name of 'morality'. The usage of religious 'morality' has often in the long past of humanity in fact meant the suppression of true human instincts of fairness and justice.
Never esteem anything as of advantage to you that will make you break your word or lose your self-respect."
I say quite deliberately that the Christian religion, as organized in its churches, has been and still is the principal enemy of moral progress in the world."
"Epicurus (Greek: Ἐπίκουρος, Epikouros, "ally, comrade"; 341 BCE – 270 BCE) was an ancient Greek philosopher as well as the founder of the school of philosophy called Epicureanism. Only a few fragments and letters of Epicurus's 300 written works remain. Much of what is known about Epicurean philosophy derives from later followers and commentators."