Although certain elements of ancient Greek and Islamic philosophy can be seen as precursors to sociology, most scholars attribute the foundation of the discipline to the period immediately following the French Revolution.
In the immediate post-revolutionary years, a key question for the French was how to reform society based on the rational principles of the Enlightenment. Henri de Saint-Simon was concerned in particular about how to use scientific knowledge to create appropriate patterns of emplyment in an industrial society in a way that would benefit all members of that society.
Auguste Comte also saw positivism as a way of objectively understanding the way society progressed through history, and creating a Utopian state founded on principles excluding the superstitions of earlier religions such as Christianity. Thus the intellectual force behind Comte was Enlightenment rationality, and the social force the French Revolution and the "laïcité" or secularism it engendered.
Next, Marxism responded to the sufferings of laborers as a result of the industrial revolution. Marx started out as an Hegelian, but parted from Hegel as seeing historical dialectic as grounded in class struggle and economics rather than in the realm of Idea or Spirit. Social Darwinism, on the other hand, was less sympathetic to those who suffered as a result of economic progress, and instead used Darwinian theory as a sort of teleological understanding of social progress, in which the "fittest" humans thrived while others failed to thrive, in part due to innate genetic superiority.
Unlike the early positivists, the founders of academic sociology such as Weber and Durkheim were more concerned with ideas, symbols, and cultural structures and patterns, seeing sociology as a humanistic discipline.
Sociology has developed into a diverse disciple. The Frankfurt school was grounded in the work of Karl Marx and critical theory and responded to the urgent need to understand totalitarianism after the horrors of the Holocaust. Especially in the wake of the Depression, sociology in the United States also developed a more empirical bent and connection with social work and the need to provide an intellectual foundation for addressing social problems.