Why some societies thrive, and others fail