For the most part they come out of emotions that evolution found useful for procreation (love, fear, anger), then extrapolated to people living in small groups, then to larger societies after the invention of agriculture via the "iterated prisoners dilemma".