As our species became more complexly social, getting food and sex came to depend on navigating a social landscape, which included goals like forging alliances and being held in high esteem. So making friends and earning respect came to feel good, and being rejected came to feel bad.