A research study published in JAMA Psychiatry on May 6, 2020 and by Harvard's T.H. Chan School of Public Health on May 6, 2020 concludes: "Regularly attending religious services associated with lower risk of deaths of despair"
(where deaths of despair are suicide, drug overdose, and alcohol related deaths).
After adjusting for numerous variables, the study showed that women who attended services at least once per week had a 68% lower risk of death from despair compared to those never attending services. Men who attended services at least once per week had a 33% lower risk of death from despair.

The study authors noted that religious participation may serve as an important antidote to despair and an asset for sustaining a sense of hope and meaning. They also wrote that religion may be associated with strengthened psychosocial resilience by fostering a sense of peace and positive outlook, and promoting social connectedness.
Correlation does not imply causation. Attending may inspire one's thoughts and perspectives to take on the qualities noted in the article's excerpt above, such as sense of hope, meaning, resilience, peace, positive outlook, social connectedness, thereby influencing the trend observed.