There are many reasons but the most important one, IIRC, is existential insecurity. The more one fears for one's wealth, health, and life, the stronger and widespread religious beliefs. The thesis goes back to Gregory S. Paul [1] and has been confirmed by others; for instance, by Inglehart and Norris (2004) [2].
As a counter-point: why does America, a liberal western democracy, still believe in God so fervently?
Australia, New Zealand, the UK and Europe have all experience a significant decline in religion over the last 100 years. Why not in the US?