The ego is developed to reflect the adherence of societal, communal rules.
You grew up in a society where survival isn’t just meeting the needs of the physical body (food, shelter, water, clothing) but also surviving the social world. Social survival relies on learning, adopting, and sharing societal beliefs and mindsets.
In order to have a social structure, societal rules and standards are set in place by… someone at some point in order to have a right and wrong way of:
Behavior
Making an honorable living
How to dress appropriately
Using silverware
The way our society goes about enforcing rules is to influence you logically but more so emotionally. You get yelled at by your parents, and you feel guilt or shame. You get a failing grade on a test, you feel guilt or shame. You start drinking again after trying to remain sober for 3 years, and you feel guilt or shame… because you are not living up to a standard that other people have set and expect of you.
Guilt and shame are fear-based emotions and that’s how society traditionally influences and perpetuates its social structure rules, through fear-based emotions. Fear based emotions include: anger, shame, sadness, resentment, annoyance. Fear reaction generates fear reaction.

