The scarcity or unpredictability of natural resources is a threat to cooperation within human societies. Exacerbated competition between individuals could affect social cohesion and collective action, generate conflicts over natural resources, and compromise their sustainable use. Yet, our in-depth archaeological study of the arid Andean highlands of Bolivia reveals the sustainable development of a complex agrarian society in a harsh environment marked, moreover, by a prolonged climatic degradation from the 13th to the 15th centuries. The 49 community settlements studied comprised independent family households that managed their own economic resources. A detailed study of the granary and housing structures of 549 of these households provided a strong quantitative data set for an analysis of Gini coefficients for grain storage capacity and housing area. This agro-pastoral society flourished with neither notable inequalities of wealth between villagers nor apparent long-lasting conflicts between villages. By sharing local knowledge, labor, and natural resources, this society succeeded both in limiting power and wealth concentration, and in sustainably producing food surpluses to be exchanged with neighboring populations. These results indicate a high degree of social cohesion and low levels of social and wealth inequality, similar to other well-established horticultural and agricultural societies around the world. We propose a conceptual model of low inequality in agrarian societies subject to extreme or unstable environments, where the sharing of knowledge, resources, and labor are the adaptive social responses to cope with the uncertainty in natural resources. The sustainability of the society is then guaranteed by a balance between collective action and family-based social organization.