The birth of sociology can be traced back to the Enlightenment.
Two important points about this era:
1) Scientific thinking was being revolutionized;
2) Religion on European continent was becoming weakened (being under attack from prominent philosophers such as Hume, Voltaire, Rousseau, etc.), and so without "God's will" as a reason for everything, there was a new need to understand social behaviour.
New "sciences" (or "-ologies") were popping up to study anything and everything. So, Auguste Comte and coined the term "sociology" to refer to the science of society.
With modernity, the industrial revolution, urbanization, etc. in the early 20th century, sociology became more prominent, with authors such as Durkheim studying such new topics as urban crime, and Marx studying worker exploitation in the factories.