What weakened religion is a long process going from the middle age to the modern world. It starts with the pope wars. It peaks with the religion wars in the XVIIth century. By this point the religious power was a political power like any other, but merely with a cultural hold on European populations. Which was the nail in the coffin.
During this period, the Church radicalised itself as a defense mode. Which solidified the laïcal mindset of the Lumières. Basically the church entered a cultural war against science because it feared it would lose controle.
Then the XIXth century happened. Monarchies got destroyed. And the Catholic Church got humiliated and destroyed as a political power. Socialism and communism appeared, and to state how progressive they were, they put the church in the same reactionary bag as the royalists.
In the middle of this are the liberals who don't care much about anything but profits. Si when democracy is on the rise, they are democrats. When royalty comes back, they praise the king. At least as long as they let them make good profits. And that's what the church doesn't let them do. Morale goes in the way of profit. It forbid slavery and exploitation. It's against science. It promotes charity. That sucks balls for the liberals. But order is good, so why not being a believer but without the problems?
It's not science that made religion recess. It's bad political decisions and alliances. Many renowned scientists were believers. Many still are. But somehow the religions are rejecting science because it doesn't go into litteraly what their old fantasy book wrote. It's a shame because religions could easily make a humanist evolution if they had the political will to do it.