A Comparative Advantage Theory of Social Interactions