According to Freud's psychoanalytic theory, we conform to society's expectations and obey its rules because our superego tells us to. It develops through early socialisation within the family, as a sort of internalised "nagging parent" telling us how we ought to behave. Its function is to restrain the selfish animalistic urges of the id.