How did the transition from an agricultural to an industrial society create the social tensions that led to socialism and communism?