Putting energy into making alkaloids, THC etc would not have continued unless it conferred something that made survival to the state of reproduction more likely. That's simple Darwininan evolution. Survival of the fittest is just that. Anything that uss vital resources but gives no advantage would disappear from the gene pool, so alkaloids must confer some advantage to the plants in question. Whether we correctly understand what that advantage is is a moot point.
If you want examples, read 'the selfish gene' or look at Lovelocks Daisyworld models
As far as cannabinoids go, the absorb in the UV spectrum, so large amounts near the end of the plant's life is to protect the seeds from becoming unviable due to UV absorption buggering their DNA. Serendipity has a big role in the incorporation of a genetic mutation within a species
With all due respect fastandbulbous, I don't buy this. I have yet to find UV absorption information of the cannabinolic acids before decarboxylations, especially compared to other components of cannabis resin. First off, I'd be extremely surprised if wild cattle fodder plants from switzerland would have any loss in seed viability due to UV exposure when transplanted to the tropics or a high UV area. I really wish it were true because it would give us an easy technique to apply selective pressure for increased cannabinoid content without needing to use a gc/ms. Although I've never done experimentation on the subject of UV exposure and cannabinoid content specifically on seed viability, I have experimented with cannabinoid protection of plant tissue against UV exposure and found no correlation between plant damage and cannabinoid content. My colleague Dave Watson of Hortapharm has conducted similar experiments with respect to whether UV exposure increases THC content over one or more generations. Again, he found no correlation. The production of cannabinoids and resin is not localized to the portion of the flower which is exposed to UV, in fact there's more weight of resin on the interior of the inflorescence where the flowers are pale green to white colored due to a lack of light exposure than on the exterior where all of the light is received. The timing of cannabinoid production is not in sync with the period when the seed is most vulnerable to UV exposure. It peaks out after the shell of the seed has fully developed. Also, wild cannabis plants with no history of domestication/selective breeding disperse their seeds from the flowers upon maturity. The trait most are familiar with where the seeds are retained in the resinous flowers occurred after domestication. Also, the period of theoretical protection of UV exposure is quite brief when compared to the life of the seed before it germinates. Also, male plants invariably possess a row of glandular trichomes on the back of the anther. I've grown wild low THC plants from all over the world and without fail they always have that row of glandular trichomes on the back of the anther. One would think that if it was solely a seed protection and UV thing, glandular trichomes would strictly appear on females.
Almost the entirety of the rare and unusual cannabinoids which have been discovered in the cannabis genus have been discovered in non-drug populations this could imply that the plant in its natural state is moving away from THC production.
The theory you're referring to with regard to UV and cannabinoids was based on some unlikely to be true historical references in various letters and diaries and studies done by the likes of E. Small which found plants in high UV areas to be more psychoactive. It's an old theory which noone that works in this field actually believes anymore. The flaw with this research was found to be that he didn't compare strictly wild or feral plants. His data was skewed because he was comparing plants from high UV areas which were selectively bred for high THC to plants in places like western europe which were feral or fiber cultivars. If he did it this way, he would have found that cannabinoid levels are roughly the same no matter what the UV levels of the area where the plant is from.
On the other hand, as I said before, THCA is antibiotic and antiviral and is a much more down to earth theory about function of this class of compounds. The timing also fits as well, the cannabinoids reach peak concentration when the flowers have started to senesce in fully pollinated plants bringing triggering mold problems. This is also when the climate in the region where cannabis is though to have evolved has cooled off and in some of the suggested regions for the species origins has also become more damp. With UV on the other hand, the earliest stages of seed development which is the closest to the summer solstice and it's accompanying high UV levels, there's little development of resin glands to be found. Unfortunately, experimentation employing exposure to pathogens as a means to increase cannabinoid content is not likely to prove this without implementing very large populations over large periods of time due to the plants having a high number of genetically controlled tools to deal with pathogen problems, including both structural and chemical traits.
What you are saying about traits disappearing is an extreme oversimplification. As I'm sure you know, traits do not just immediately disappear once they no longer help and the level of detriment or advantage determines the selective pressure and speed with which the trait disappears. In this case, talking about THC synthase, we're talking about very small demands on resources, with no alternate genes at the specific locus which have less of a demand on resources. The key here is 'anything that uses vital resources' VERSUS THE ALTERNATIVES. If the current alternatives, even if they're null genes that still code for an enzyme, albeit a nonfunctional one, then there's no decrease in demand upon resources because there's still an enzyme being produced and the gene requires the necessary mutations to become a totally unused genetic code.
Phenotypic traits themselves do not necessarily have to bring a benefit to be selected for. The gene which produces a given detrimental trait may also bring a trait that is so useful that there is a net gain in desirability. There's also quantitative phenomena where a gene which seems nonfunctional or detrimental needs to be present for another gene to function properly. Then there's the subject of gene linkage. Although it is not incorrect to say that traits which demand valuable resources but pose no benefit probably indeed EVENTUALLY leave, this can take massive periods of time especially if they don't bring a statistically significant disadvantage, for even the most simple of genes depending upon how the genome is structured and whether or not a mutation occurs at the right place in the genetic code at the right time. Also, not all resources are valuable. Some regions have certain soil nutrients in overabundance. Sometimes having a gene which seems nonbeneficial can draw on a resource pool which causes a trait which shares the same resource pool to express in a manner which is beneficial, but given an decrease in other demands on that resource pool the gene becomes detrimental, again it is not the expressed phenotype of the gene which helps the species but the underlying mechanics. In practically all mammals and flowering plants you can find evidence of nonfunctional vestigiality. Genetic code itself is not efficient like a well written segment of code written by a resourceful computer programmer, it is filled with vestigial code that does absolutely nothing. in most organisms genetic code has a high percentage of vestigiality. I tend to disagree with dawkins on this to some extent, who seems to imply that all genetic code would tend to evolve to be less wasteful and more eloquent. I believe that all of the nonfunctional code and inefficiently written genes increase evolutionary potential. A computer program which is written eloquently and efficiently is likely to lose all functionality should a transcription error (mutation) occur. however, an inefficiently written piece of software is much more likely to retain or gain a new different functionality should a transcription error occur. Thus vestigiality increases evolutionary potential.
Also, when you're talking about an enzyme like THC synthase which really doesn't employ a huge enough amount of energy to put an individual at a statistically significant level of disadvantage against no enzyme at all there's little evolutionary pressure to remove a gene. I'm sure you can find many instances of vestigial enzymes which perform new but albeit less than beneficial functions. Also, not all resources are vital. For example, some regions have soils with an overabundance of certain nutrients. As I said before, B locus does not have any alternative alleles which use less energy than the Bt allele, of course this is after the synthesis of CBGA, a cannabinoid.
Just as maize evolved under cultivation with it's wild ancestors being simple grass plants with a single mutation bringing about the large corn cob we know today that was then selected for, it is entirely possible that the Bt allele which allows cannabis to produce appreciable quantities of THC
could have also evolved under cultivation. The cannabis plant is though to have first been cultivated as a food and fiber source, so it is not a huge stretch to think that this very simple mutation could have occurred in a population that was being cultivated and propagated by man. That said, there is one evolutionary advantage of the Bt allele over the Bd allele and that is in plants which are otherwise genetically identical, homozygous Bt plants and heterozygous Bd/Bt plants have a tendency to produce higher cannabinoid levels than homozygous Bd plants. The mechanism of this is not fully understood, at least not by me. It may be that CBDA synthase in some way interferes with GOT, the enzyme which synthesizes CBGA. All of this would be totally separate from the fact that homozygous Bt plants tend to occur in populations which have been already selected for drug content and is in reference to all other things being equal, i.e plants from the same population that contains both Bd and Bt alleles.