Why and how does the sun affect our mood?
Shar is partly right as is FOS.
Yes the sun affects our production of Vitamin D.
The Sun (or more correctly light of various frequencies) affects the rate of production of many different chemicals within our bodies, one could go so far as to say most different chemicals within our bodies.
Some reactions are enhanced, others are inhibited, some effects are magnified by other systems, some are damped and inhibited. We understand so little of the vast subtleties that happen in the biochemical machines that are our bodies, and even less of the levels of software systems of our awareness that run within our brains.
So as FOS says, I am confident that the sun does affect us in many ways we understand little or nothing about. I understand many of the general ways that it does so through biochemical pathways, but very little about the specifics. I suspect that there are many other subtle ways that the sun affects us, that are not directly biochemically mediated.
I know I like the heat that I get from the sun on a cold day, not so much on a hot day.
I know that I have not felt great when I have not experienced sun for weeks on end. When I was working on squid jigging boats I could go weeks without seeing sun over winter – working all night, and sleeping when the sun was up.
Once spent a few days deep underground in abandoned mine shafts – and remember how weird that felt.