Why do people have darker skin in sunnier climates?
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.