The ego is the sense and belief of being a separate self, being a human separate from the rest of the world. The ego forms in the mind as a child develops, where the mind thinks that this body is me and these things are mine. Often as the ego grows, it develops its sense of separate self by belonging to a group and embracing that identity, or being distanced from a group, which also strengthens its sense of identity.
In human society identity is super important. We identify with our gender, ethnicity, nationality, political view, or religion. But truly none of this is who we are. The ego isn't real. The ego is a mistaken identity assumed in the mind.
Just because the mind perceives the human experience and identifies as a human, with a human history, it doesn't mean it's true. And just because the mind also holds on to objects and calls them mine, it doesn't mean they really belong to it. We need to go deeper than the mind to find the truth.
Truly we are Consciousness perceiving human experiences. We perceive the mind, the ego identity, the thoughts, the human feelings and sensations, and the perceptions. We perceive the ego identity saying I am this, these are mine, and I did that. We perceive the ego assuming identity and assuming separation is real. Separation isn't real. There is only One. There are no separate objects, and there are no separate identities who own them. It is all a play of separation.
Recognition of this understanding leads the ego to a deeper understanding of reality. As the truth dawns, the ego fades. Its ways of selfishness are no longer relevant. The phantom ego effectively disappears, but it was never a real thing anyhow. This realisation will come to the soul, to the human and to humanity. Humanity will in time awaken to the realisation of not being separate. It's spiritual development will bring it to the realisation of Oneness.