Originally Posted by Wikipedia
Trichomes evolved on cannabis to prevent herbivory/parasitism by small insects. In the wild, insects landing on a cannabis leaf become adhered to the trichomes causing death or lost time (see sundew) and in addition will absorb the cannabanoids and, so intoxicated, experience increased rates of predation and loss of will to escape. However, the intercession of man in the natural selection process has rapidly accelerated the favoring of genotypes that produce copious amounts of THC laden trichomes. In addition, THC has very high UV-B absorption properties, thus cannabis evolution may have favored the evolution of genotypes that produced these THC laden capitate-stalked trichomes as a built in 'sun-screen' for protection against UV-B light rays.