The evidence on this seems to be changing frequently, not unlike the evidence on whether taking vitamin supplements is a good idea (
https://www.health.harvard.edu/staying-healthy/should-you-ge...). Generally speaking, the latest science on nutrition seems to be more subject to later revision, or even reversal, than the latest science on, say, physics or geology.
So, while we wait (perhaps decades) for nutrition to become a more reliable science, I like to consider it from an evolutionary angle. That which is very dissimilar to what my ancestors experienced, like plentiful sugar or a sedentary lifestyle, is more likely to be bad for my health.
Exposure to the sun for hours a day, including the UV part, was part of our ancestors' lifestyle from the beginnings of our species, until a few decades ago. Now it is possible that this is the exception, and we should keep ourselves shielded from UV at all times even though it was what we evolved for. But...
- we don't now much about our skin microbiome, but we know we have one and it matters, and it seems unlikely that removing all UV would not impact that
- we know there's an impact on vitamin D levels, but the details of that are still unknown
- we know that eczema, psoriasis, and other skin conditions have been rising in recent decades, since the "always wear sunscreen" advice became common
Now, many that's all a coincidence, and UV is bad for us, and lack of UV is good for us, regardless of the fact that it's the environment we evolved for. But I'm skeptical.