A lot of research would say that it can and does. Social support seems to help, but with spiritual beliefs, people seem to live even longer and healthier lives. They are kept active, still make meaningful contributions to others, and, of course, they continue to practice their religious beliefs. We think it partially has to do with feelings of control. A religious or spiritual person both simultaneously gives up control to the being they worship, and by so doing, gain more control over their total existence.
Religion generally gives positive purpose and cause to living.
Religion or spiritual beliefs can provide meaning in a world that can otherwise feel random and without meaning. Prayer also seems to play a role. When people pray, they engage in a type of meditation, relaxation experience. This has a dramatic impact on stress. Even when people pray out of desperation, they report a feeling of relaxation after prayer.