> This is true. However when a country is sufficiently developed it may no longer need religion. The functions that the Church used to provide (education, healthcare, charity) will be taken over by the State.
This is quite wrong - the main beneficial function of religion is to provide an institutional framework for enhancing social capital and the overall "sense of community", which is a critical antidote (far more so than "welfare" or even private charity) against social exclusion and marginalization for the most vulnerable in society. The only states which try to take over this function altogether are totalitarian states - in fact, even in many authoritarian or otherwise dysfunctional and unfree states, religion - at least at a "grassroots" level - tends to function in practice as a haven for civil society. The only institutions that even compete would be labor unions (in some places), and for obvious reasons these are far less universal in their overall outlook.