It's a very complicated political science question, and to be perfectly frank, I'm not qualified to answer on the history going all the way back to 1945, when independence started. The short answer is that what you have is a country in which really extremist elements, in the political scene, mostly Sunni, in one way or another were kept under control or were sidelined or were subjugated in one way or another from 1945 until roughly five years ago.
First, the Suharto era ended, but in the fallout from that, what you saw was certain, quite extremist Sunni groups becoming more and more powerful politically, and instead of being co-opted or in some way sidelined or for political reasons softening their tone, they seem to have grown increasingly strident. Unfortunately, many of their followers seem to think that the way to get things done on the local social level is to use kinetic force, to use violence. If there is a Christian church and they don't like it, they'll burn it down.
I won't even get into the more complicated issues or the fact that some of these more extremist groups have enjoyed a kind of uneasy relationship with state security apparatus over the years. There are accounts collected by the International Crisis Group and other NGOs in which police and security and intelligence folks have admitted that essentially extremist Sunni groups were used by the police as their “attack dogs” at various moments for political reasons. That's a whole complex issue in itself, and there's a question to be asked whether the government created a monster by using radical groups to be off-the-books mobs for hire.
At the end of the day, the answer to your question is that about five years ago very extremist groups gained more political power than they've ever had. The current president's religious affairs minister, who I was just talking about, who is so hostile to Shia and Ahmadiyya, was given that position because the president has a coalition government and he needed to give him a position. It's almost like politics was the reason that guy got that position and why we have him now, and why he can't be fired by the current president, no matter how much we complain about him.