Evolution of the social contract