Was it the religion or that sense of shared community?
This is armchair sociology (really though, is there any other kind of sociology?), but I would argue that it's two things, neither of which have anything to do with "morality" or whether any particular religion is true or false:
1) Shared community, as you mentioned. For lots of people, church used to serve as something sort of like an Elks Club. The decline of church attendance would tend to weaken community bonds. Not for everyone of course. We're talking at the 30,000-ft "community" level here, not the individual level. Many people don't need strong social bonds -- I know that because I'm one of those people. But I think we all can agree that communities are less cohesive than they were a few decades ago. It's not like I'm the first person to make that observation.
2) Sense of purpose. One thing that religion definitely does, explicitly so, is give people structure and purpose to their life. Again, on an individual level, lots of people don't need that. This forum in particular is filled to the brim with people who can provide self-direction -- I am one of those people, and I can point to a whole bunch of kindred spirits here, by name if pressed. But most people aren't like that. Take away religion, and they'll either find themselves directionless, or they'll glom onto a political cult, materialism, or some other unfulfilling alternative.
Notice that this argument would be the same if the US were mainly an Islamic country instead of being mostly Christian. This is sociology-of-religion, not really religion per se. I think it's basically the same argument I was making in that thread. My experience of living in the US since the early-70s and watching how things have gone has led to think that probably societies function better if there's somewhat more shared community/purpose-making than what we have right now. As an ardent individualist, this is not the conclusion that I ever saw myself drawing, but I can't deny what's in front of my own two eyes.
Edit: Also, I know it's not
just religion. Stuff like this is almost never monocausal. I used to think that it was great that we have a million different streaming services so that each of us can watch what we want and tune out the stuff we don't want, and I still feel that way, but that's another area where we just don't have a shared culture anymore. We're never going to have another "Who Shot JR?" moment, and we'll never have another Cronkite. On net that's almost surely a good thing, but it has a downside in atomizing society that much more. We could go on and on about this topic. It deserves a book-length treatment.