It might make a difference for some people. For example the link between back pain and depression is well known. Long-term benefits of exercise have also been shown both physically and psychologically.
A group exercise class may help depressed patients feel a sense of belonging. This kind of social support may be what helps some people the most.