For most of history, people have been on the borderline of survival. That's changed dramatically. Survival is certain for almost everyone (in the West). So one of the reasons people are drawn to religion has eroded.

The declining (church) attendance is really dramatic, but what is even more important is that the churches are losing the ability to dictate to people how to live their lives.