The sun emits many different frequencies of light, only some of which are visible
The nuclear reactions within the sun are constantly producing light. The details of solar activity are complicated and can have nuances that still are not well understood by scientists, but we do know a lot about the nature of light that the sun emits. Physicists call the sun a blackbody radiator, which refers to the light that is emitted from an opaque, non-reflective (hence black). It turns out this spectrum of light depends only on the temperature of the object, and the sun can be approximated as emitting such a blackbody spectrum based on its surface temperature of about 5000 kelvin. That has important implications for the nature of light that we see, but the details are another (upcoming) post.
Our sun emits quite a lot of visible light, but many other frequencies of light as well. The most harmful of these—x-rays and gamma rays, for example—get stopped or scattered in the Earth’s ozone layer, which is why it’s critical to protect. Light with frequency closer to the visible spectrum can get through this layer and reach the ground—this includes ultraviolet light, which has frequencies just higher than the visible spectrum, and infrared light, which has frequency just lower than visible.
Clouds are good at blocking out visible light, but not other frequencies
Clouds consist primarily of water vapor or water droplets, and this determines the way light interacts as it travels through them. The details of how visible light scatters in the cloud actually results in their white color, but that’s another post. It’s certainly true that dark clouds appear that way because their increased water content blocks light from passing through to reach the ground.
This isn’t true of all frequencies, though—visible light is scattered or absorbed quite well within clouds, but not ultraviolet or infrared light. In fact, a good rule of thumb (with plenty of counterexamples) is that if a material is transparent in the visible light range it is probably opaque to infrared and ultraviolet light, and vice versa.
Ultraviolet light mostly goes through clouds, and is responsible for sunburn
Ultraviolet light, for example, is only cut down by about 30% when there are many clouds in the sky. Even if the sky is dark from overcast clouds as much as 30% of the UV light from the sun will still penetrate and reach the ground.
Ultraviolet light is responsible for the skin damage that results in sunburn, and subsequently in tanning. The sunburn is a result of the ultraviolet light causing damage directly to the DNA as it is absorbed within skin cells. Part of the body’s response to this damage is to cause the cells to die, which will eventually result in skin peeling. Increased melanin production is also triggered, which is a chemical that absorbs ultraviolet light and serves to protect the skin somewhat from further sunburn—as a pigment, it’s also responsible for skin tanning.
Nowadays you’ll see sunscreen that claims to block two types of ultraviolet radiation: the UVA band, which has frequency just higher than violet light, and the UVB band, which has frequency just higher than the UVA band. These two different regions of the ultraviolet spectrum are emitted from the sun with different intensities, and interestingly they affect skin in different ways. UVA light penetrates deep into the skin, and is the primary contributor to tanning. UVB, on the other hand, doesn’t penetrate skin as deep but is primarily responsible for the reddening and pain that is sunburn. It’s important to protect against both bands of ultraviolet light in order to prevent skin damage.