There was natural selection for the belief, “I am of value, full stop.”
1) Why? The belief increases the probability that we will start and stick to projects that are in our medium to long range interest.
2) How does it do that? Anything that is of value should be preserved. It should not be damaged or destroyed. Projects that are in our medium to long range interest are projects that tend to preserve us. Believing that we are of value therefore increases the probability that we will engage in, and complete, projects that preserve us.
3) What is an example? Working a hot summer’s day with a view to preparing for winter when it is more tempting to go swimming.
4) Wouldn’t we still be selfish? Initially, yes. But there would also be selection for co-operation with others who also believe that they are of value, because a group can do more than an individual can. Others would demand recognition as valuable beings before they would co-operate. Once someone acknowledged others as being of value, they would be committed to refrain from damaging or destroying them, and committed to preserving them from damage or destruction. They would be committed to believing that they are equally valuable. Moral communities would develop. Incidentally, this is not an explanation of co-operation itself but of the unique form of human co-operation.
5) Then why would we have to care about strangers? It would be inconsistent to acknowledge some others without acknowledging all others unless there was a relevant difference, and there would be no relevant difference.
6) Why shouldn’t we be inconsistent? There would be blowback that would eliminate the advantages of believing that you were of value. You would be committed to believing that you both were and were not of value. Consequently, you could act only in ways that were consistent with both, which would cancel out the benefits of believing that you were of value. (We can act in accordance with both a proposition and its negation: drinking coffee in the morning is consistent with Socrates being mortal, and also consistent with his being immortal.)
7) Wouldn’t one person have to give their life for others? This would have been a problem in the evolution of morality. A solution to the problem is to add a breaker that would turn the belief off automatically if people otherwise had no choice but to sacrifice themselves. They would have obligations to save others only when they could desire to avoid injury or death more than anything else at the same time. People could die for others voluntarily but they would not have an obligation to do so.