The drive of early sociology in the late nineteenth century was the enormous changes the industrial revolution brought with it. These changes were unrivalled in their wide and profound effect on society and in the speed by which these changes came about. A clear distinction became apparent between the pre-industrial primitive and static society and the dynamic, industrial, capitalist modern society.
What brought on these changes?
Well, the answer to that question is obviously an extremely complicated one. Karl Marx believed that it was an inevitable consequence of history based on the economic and political preconditions. Max Weber disagreed. For one, he didn't believe there was anything inevitable about it. In fact, Weber noted that these changes occured in some civilizations, but not in others: This pointed to the fact that a wide array of factors had to coexist. Secondly, he didn't subscribe to the view that the philosophy and ideology of a given time is given by the 'material' economic preconditions. Quite to the contrary, Weber believed that it also worked the other way around: That the beliefs and ideology of a civilization can cause changes in its economic and political constitution.
In the beginning of the 20th Century, Weber's The Protestant Ethic and the Spirit of Capitalism was published. The "Spirit" part is important, because while Weber did not discount the fact that a wide array of economic factors had to be present for capitalism to develop, those factors could not explain what created the motivations of the people living the capitalist way of life.
The motivation, in the view of Weber, originated in the religious changes that came with the Reformation in Western Europe, especially the influence of Calvinist doctrines. This new Protestant ethic of being austere and diligently and efficiently doing your duty is in fact the spirit of capitalism.
A central thesis in Protestant thought (at least at the time of Reformation) is that everybody has been called by God, in His all-knowing wisdom, to the station and position they possess in society. Thus it would be in conflict with the grand scheme of things if you were to work with less than absolute enthusiasm and perseverance no matter what appalling hardships the Almighty had chosen to test you with.
This, emphasised because of the writeup above, is in contrast to the monastic existence idealised by the Catholic Church. By cloistering yourself you work against what God put you on Earth to do.
Also, and equally important, was the question of eternal salvation. Calvinists believe that everything is predetermined, and God has already chosen which souls will be saved and which souls will be damned. Nothing you can do or say will change whether you go to Heaven or to Hell. But, naturally, you aren't omniscient like God, so you don't know where you will be spending your afterlife. Which is rather unnerving.
Calvinists did worry a lot about this, and even though Calvin had said that the rituals and 'good works' of the Catholics were nothing but idolatry which won't change God's plan or influence him in anyother way, they came to the conclusion that if everything is predetermined it would make sense if those who will be favored with eternal salvation eventually is also the ones favored in their life on Earth. In other words, if you act in a fashion pleasing to God, it could be a sign of divine favor. And as you do God's work by doing your job, and not by doing charity or meditating in a monastery, it is sinful not to add to God's greater glory by taking every God-given economic opportunity you are offered.
Finally, since your actions have no influence on whether you will be saved from eternal damnation, and thus you have no way of repenting or making penance, and since your earthly conduct is a sign of whether you are enjoying God's good grace, it is of vital importance that that conduct is in fact to God's liking. Any straying from the narrow road could be a sign that you are not going to be saved, and obviously this creates the incentive for strict self-moderation and self-discipline.
That all combines into the Protestant work ethic. And whether or not God is in fact invoked, it is also the spirit of capitalism. Said Weber.