The ego develops in order to mediate between the unrealistic id and the external real world. It is the decision making component of personality. Ideally the ego works by reason whereas the id is chaotic and totally unreasonable.
The ego operates according to the reality principle, working out realistic ways of satisfying the id’s demands, often compromising or postponing satisfaction to avoid negative consequences of society. The ego considers social realities and norms, etiquette and rules in deciding how to behave.
Like the id, the ego seeks pleasure and avoids pain but unlike the id the ego is concerned with devising a realistic strategy to obtain pleasure. Freud made the analogy of the id being a horse while the ego is the rider. The ego is 'like a man on horseback, who has to hold in check the superior strength of the horse' (Freud, 1923, p.15).
Often the ego is weak relative to the head-strong id and the best the ego can do is stay on, pointing the id in the right direction and claiming some credit at the end as if the action were its own.
The ego has no concept of right or wrong; something is good simply if it achieves its end of satisfying without causing harm to itself or to the id. It engages in secondary process thinking, which is rational, realistic, and orientated towards problem solving.