In Freud’s psychoanalytic system the ego was that very thin slice of the human psyche where determinism made way for the free, willing individual.
Internally there was the id, all of those powerful instincts, drives, and motivations that constantly sought satisfaction. Externally there was the super ego, all of those powerful rules, norms, and tabus that sanctioned appropriate behaviors while putting checks on id strivings.
In the middle of it all was the ego, whose job it was to mediate, to find some sort of balance between id and super ego, to choose the behaviors that would satisfy both. Freud called it sublimation when this process was successful, when the id was expressed through healthy channels without a lot of negative consequences from the environment. Sublimation was responsible for the building up of civilization, for art and literature, for the healthy functioning of the individual.
Whatever negative views you have about Freud’s theories, when you free them from their libidinal restraints and apply them in more general ways they become powerful explanatory principles. This interplay among id, ego, and superego is no exception.
A lot of conflict in human life occurs precisely because of the contradiction between what we really want for ourselves and what authority in all its many guises tells us we want for ourselves. When we’re not able to find an adequate solution to this conflict the result is usually psychic disturbance, either because we follow external demands to the exclusion of what we really want or because we follow what we really want to the exclusion of external demands. Either of these paths causes distress, the one due to the pain of betraying ourselves and the other due to the pain of all the negative feedback and various sanctions.
Of course, the last paragraph sees the Id through an existential lens, where our internal strivings are themselves growth oriented, where they don’t need to be sublimated because they already represent the path to the highest actualization of who we are. Freud, on the other hand, saw these internal strivings as basically harmful, as instincts that if let loose on the world in their raw form caused a lot of problems. Freud was right that some instincts are harmful. The existential goal becomes raising conscious awareness about which internal strivings represent who we can be and which represent who we don’t want to be, a choice that takes place at that thin slice of human freedom called ego, the slice where as conscious beings we have the ability to decide which strivings we are going to enact and which we are going to contain, not necessarily because the super ego tells us to do it but because we have decided of our own free accord where our true path lies and what we need to do to walk it.