The way I see it: If you live where your ancestors lived for thousands of years and if you make sure your skin gets gradually attuned to the sun each year, you probably get more health benefits. But beware if you're of Northern European ancestry living in Southern USA or Australia or if you work an office job and only seek the summer sun with pale skin.
I have no reliable and in-depth data on how many of my ancestors died of skin cancer, or how many hours they exposed themselves to sunlight, and what kind of sunlight, or what clothes they wore over those thousands of years.
Using this line of thinking is at best an attempt at rationalizing what lifestyle you wanted to live anyway.
Melanin helps protect from DNA damage by absorbing much of the UV radiation. As you get more exposure to sunlight, your skin produces more melanin resulting in more protection.
A sunburn is what you want to avoid and it's easier to get when you stayed indoors the whole year and only go outside when the sun is out full blast. I personally think this modern lifestyle is one of the reasons people get more skin cancer despite being outside less. There are studies that show that chronic sun exposure isn't that bad.