According to the original psychoanalyst, Sigmund Freud, our ego is part of our personality that is between the id (our primal, animalistic instincts), our superego (the mature personality formed by the kind of upbringing and social influences in one’s life) and reality.
The ego works based on the reality principle, which strives to satisfy the id's desires in realistic and socially appropriate ways. The reality principle analyses the costs and benefits of an action before deciding to act upon or abandon impulses.
The ego has its one internal, silent and invisible measures, known as defense mechanisms to curb the ‘id’. These measures are not visible and can only be known retroactively, like repression, for example.
Our basic and primal instincts are regulated by our ego, and our more moral and idealistic standards, set by the superego, are also kept under check. The ego operates in the preconscious, unconscious and conscious states of the mind. Example: The ego is a safety valve that prevents us from getting out of the car and attacking the driver that has offended us for some reason, however satisfying that may seem at the moment.