I don’t recall the precise social-science terminology for the following concept, but there must be some neat one. Anyway, the Mishna in Avos says to acquire a friend. Rabbenu Yonah ‘on site’ explains one aspect of this advice, using a known Talmudic principle (in a wider sense): אין אדם חוטא ולא לו; one does not sin for another’s benefit. Therefore, having a friend, even one no more righteous than myself exerts a degree of pressure on me to refrain from transgressing.
That is, sin is a selfish endeavor. Or, put in a spiritual way, my friend’s evil inclination does not lead him to encourage me. What is left? The less subjective nature of wrongdoing; harmful in this world, the next world, or both.
As the Gemara says: כשאדם עובר עבירה אומר ולוואי שלא יראני אדם