Humanity was never a solitary creature.
We evolved from troupe animals from millions of years ago - humans cannot live alone without any support from other humans (some humans do, but these are anomalies)
Given that you need to live in a group, you cannot survive by taking what you want at the cost of hurting others.
Over time game theory ( in prisoners dilemma terms ) goes from a population of
- A stable population ratio of defectors and co-operators
- Introduction of “tit for tat” strategies that reduce defector populations
- Evolution of “turn the other cheek” or “tit for two tats” forgiving policies
- Eventual domination of co-operators with a generous mix of “tit for two tats” who are lawmakers and a small contingent of “tit for tat” who are police and military
- Evolution of a small set of “smart defectors” who are able to identify co-operators and exploit them by defecting (conmen / sucker-punchers / criminals)
- As the “smart defectors” get smarter, the “tit for tats” need to also get smarter and sometimes they may evolve to preemptively defect to catch the “smart defectors” - This leads to phenomenon where law is abused due to police etc.
In short, values are nothing special - they are evolution of game theoretic strategies, some unconscious (like empathy from mirror neurons), other due to conditioning and culture (like “do unto others ….”) and some conscious decisions to act in a particular way, based on reasoning about ethics.