Neuroscientists studying the brains of monkeys noticed that certain neurons fired when an individual performed a certain action. To their surprise these neurons also fired when the subject watched another monkey performing that action.
They speculated that these 'mirror neurons' evolved in order to give highly social animals the ability to create simulations of the minds of other individuals. This would allow them to predict how others might behave - a valuable survival tool.
So the theory goes that we had a sense of other selves before we had a sense of our own self. Then over time this ability to simulate selves was turned inward (introspection) and the sense of 'me' developed.
The human mind is the product of these simulations of 'other' and 'me' (the superego and the ego) and have developed to become so convincing that it is extremely difficult to see the reality beyond them.