A lot of gym rats are fucked in the head, but its not because they work out, rather people work out to cope with anxiety and depression. High intensity aerobics and even oxygen itself are natural highs so they give people temporary escape from their problems. Also, like many other things exercise can be addictive.
On the other hand a bad diet and lack of sunlight and exercise will lead to mode and behavioral issues. Humans evolved as migratory animals, we were not meant to sit on our asses all day in front of a computer. Our emotions are not solely produced by the brain, our microbiomes play a role too.
TL;DR: healthy body =/= healthy mind but healthy body=healthier mind
you still still work out and eat healthy cause even if you're still fucked in the head at least you'll be hot