I think that this question needs a complex answer and I try to mention some aspects of it only.
There are different reasons for this relatively small terror group to sustain.
First of all they have support from many different countries, financially, ideologically and training wise. There are various evidences that US, UK, Saudi Arabia and Turkey, only to name a few but most powerful ones, are directly and indirectly supporting IS. So IS is not a small group of insane terrorist with limited resources but a tool in the hands of world powers.
https://www.youtube.com/watch?v=ojcoKnTGf4s (Interviews with General Wesley Clark)
They were created to use religion for political aims.
They follow the ideology of Wahhabism which was created by the British government to succeed in the fight against the Osman Empire. The British used an already existing tendency which had developed in islamic history after the prophet ( but is not part of the original teachings) and lifted it into power. Later on the Saudi state was created which spread its violent ideology firstly over the Arabian Peninsula but with the vast amount of profit from oil sales, Saudi Arabia spread Wahhabism all over the world.
Of course this ideology found supporters and sympathisers in the Sunni Muslim population. Unfortunately not all Muslims are well informed about their religion therefore they can be fooled to believe they would act in favour of their religion when in fact they act against its teachings.
They found supporters among ordinary Muslims who were attracted by this ideology. For this reason IS was welcomed by some communities in Iraq and Syria. By the time people realised their true, vicious and inhumane behaviour it was for many too late to act against them, as they themselves became an enemy for IS and being threatened by the most horrible acts of beheadings, life burnings etc. What can you do then as a normal citizen without weapons when the terrorists have taken over your town?
In Iraq there is a popular uprising against IS since the highest religious Shia authority has issued a decree that it is the plight of the Iraqi people to defend their country and fight against IS terrorism.
Since then, more than 2.5 million (this number in from 2014, current number is even higher) popular fighters (in the majority Shia) have joint in the fight against IS and have liberated together with the Iraqi army around 40% of IS controlled areas. More and more Sunnis are joining the PMF (Popular Mobilisation Forces). These young man decided to leave their families and risk their lives to fight for their country instead of fleeing to safety into neighbouring countries or even further. And they do so to free mainly Sunni populated areas which are under IS threat.
The PMF is a rebellion of the people against terrorism, but properly organised with the support of the government and affiliated to the Iraqi army.