The ego is mostly who we are. Everything about us that is us is based on our ego. Even seeing ourselves as something separate from the ego is our egoistic outlook. The ego is both a misguided friend and dangerous adversary as well as wise counsel and staunch advocate. To only see the ego as bad is only seeing half the picture.
The ego has its use in society. Our society is built on a collection of individuals. We get a birth certificate at birth and a death certificate when we die. We acquire possessions, things that belong to us, we register to vote and are responsible for our crimes. All of these activities of quantifying the individual stem from an ego based outlook. Our ego is that part of us that is us.
Buddhism is based on the idea of no-self. It teaches that when we look into what it is that is uniquely us, there is nothing there. Every bit of us is interconnected with the rest of the universe. Because no-self is a radical and counterintuitive idea, the idea of ego was born to represent what we perceive as self.
Buddhism also claims that the root of suffering is ignorance, which is believing in the ego, believing in a separate self. That gives ego its bad reputation. We live in a world of egos, so it is helpful to be able to live as an ego, but keep looking for the truth of interconnectedness. When interconnectedness makes more sense than separate selves then we get a good look at ego.