Shared religion is a factor in a sense of shared culture and identity in a nation-state. Religion, or lack thereof, is an integral part of a person's identity. People tend to group up with people of the same religion, and it helps to create a cohesion among people. It can also be used to motivate and bring together the people of a nation, calling for war, peace, or any other large-scale activity in the name of the nation's religion.
Religion (and other civic associations) provide an outlet for public opinion that is often critical of the nation-state. Outlawing religion doesn't work unless there are no other civic institutions such as unions, political parties, and local governments. Religion is always the way to speak out against the nation-state even if the leaders are chosen by the state because the prayers of groups of men can be done without leaders.