I don't understand why darker skin is advantageous in hotter climates. Wouldn't it absorb more of the heat? I have heard that it reduces the incidence of cancer, but I would think absorbing more radiation would increase the risk?
One of the important pigments that the earlier answer hinted at is melanin. Melanin is a brown pigment with photoprotectant properties.
As you correctly identified in your question, exposure to EM radiation (particularly UV and shorter λ waves) is damaging (indirectly) to DNA, which can cause mutations and therefore possibly cancer. Melanin production is one of the defence mechanisms the body has evolved to deal with this threat.
When DNA is damaged by the UV-B radiation, melanogenesis (the increased production of melanin pigment) is induced.(1) Therefore, people often exposed to more UVB (i.e. in sunnier climates) are likely to have more melanin in their skin, which makes it appear darker in colour. It is likely to be the increased incidence of melanin proteins in your skin which leads to the formation of a tan.
Melanin and its derivatives work as photo-protectors (protecting the body from the damaging effects of ultra-violet exposure) by absorbing UV-B photons and converting them into much less damaging infra-red wavelengths (heat energy). It does this extremely rapidly by internal conversion and extremely efficiently - efficiency in excess of 99.9% has been reported.
As the melanin removes the danger posed by the UV within a few femtoseconds (x10-15 s), the more melanin that is present in skin tissues (and consequently the darker the skin), the lesser the chance of the UV damaging molecules in the skin so the lesser the risk of developing skin cancer.
I heard one proposition that has to do with cancer, and the other side of the coin is related to vitamin D and calcium. If I remember correctly, living in a sunnier climate can affect your skin and cause cancer. The trick is to produce pigments in the epidermis so that the radiation is absorbed by the pigments and doesn't go further inside into the dermis, where it could cause DNA damage to the living dermis cells. The epidermis is constantly shedding dead cells out, so apart from absorbing more heat, there is no problem in absorbing radiation in the pigments at the epidermis level.
Having lighter skin in cloudier climates favors the absorption of sunlight, which is necessary for the production of Vitamin D, which in turn is necessary for the regulation of the levels of usable calcium in the body. Not having enough calcium is associated to all sorts of diseases.
The claims for VitD/calcium/sunlight are sometimes also associated to lactose tolerance in adults. The scene we see in pictures where someone wakes up in the middle of the night, opens the fridge and downs a gallon of fresh milk is actually not applicable to most of the human populations. We are lactose tolerant during our infancy, but for most of us, lactase production slowly shuts down when we grow up. The claim related to calcium metabolism is that human populations living in cloudier climates became adapted to lactose tolerance in adulthood so that they could make use of the calcium available in milk, and that extra calcium would contribute to a balanced calcium metabolism given that there is not much sunlight in their climates.