This research is dedicated to differences between cannabis plants producing THC and hemp plants, and factors that affect THC synthesis.
What is the difference between cannabis plants that produce THC and plants that do not produce THC?
Cannabis plants could produce more than 100 cannabinoids, which are mainly accumulated in female flowers (“buds”). The main psychoactive cannabinoid is Δ9-Tetrahydrocannabinol (THC). It has analgesic, antiemetic and appetite-stimulation properties.
A research on genome of Purple Kush and hemp autoflowering cultivators Finola and USO-31 has aimed to identify the differences of THC production between “drug type” and “non-drug type” cannabis. The authors discovered that the genes encoding cannabinoid pathway enzymes are expressed mainly in three stages of flower development: pre-flower and flowers in early and mid-stage of development. This means that during these periods the production of cannabinoid is the most intensive. This finding is consistent with the fact that cannabinoids are synthesised by glandular trichomes, which are expressed in high density on female flowers.
The difference between Purple Kush and hemp plants is the presence or absence of THCA synthase (enzyme, responsible for THC synthesis). The authors discovered no major genetic differences between the plants and they suggest that high THC production is result of breeding selection and upregulation of THC synthesis mechanisms. 
THC evolution theory
According to one of the evolution theories THC was produced from cannabidol under the influence of intense ambient UV-B of the tropics. 
Can you breed high THC cannabis plant, using hemp?
De Meijer and his team have crossed high THC cannabis plant and high CBD plant. In F1 they observed hybrids with intermediate ratio of THC and CBD. After selfing the plants in F2 they observed 1:2:1 distribution – 1 (THC dominant plants); 2 (plants with mixed THC and CBD production) and 1 (CBD dominant plants). [1, 2]
Further research confirmed these observations. According to one of the hypothesis THC and CBD synthesis trait is codominant (both expressed as dominant trait), which explained why THC and CBD were expressed in all F1 hybrids. 
Do more trichomes mean more THC?
There is a research on correlation between amount of trichomes and THC synthesis. The authors have studied 3 different cannabis plants, which were genetically uniform and clones material was provided during several years – “drug type” plant with high THC, “non-drug type” with high CBD and “fibre type” with low CBD. They have discovered negative correlation between the amount of glands and cannabinoid contests – more glands do not mean more cannabinoids. Therefore, the authors suggest that cannabinoids could be synthesised in other plant parts as well. Also cannabinoid content can vary not only between different cannabis plants from the same strain but even between different plant parts of the same plant. The only trend observed is that gland number and cannabinoid content decrease with plant organ maturation – ageing cannabis plants will have less glands and lower cannabinoid content. 
What is the precursor of THC?
THC is derived directly from CBG: CBG – THC. 
Do conditions affect THC synthesis?
According to some authors THC and other components act like a barrier to water loss in dry environment. Other authors have observed that increased THC production is characteristic for places with short rainfall periods, low humidity and sunny climate. There are suggestions that THC production is related to plant stress – high stress leads to higher THC synthesis. 
There is no clear relationship between temperature and THC synthesis. According to some authors temperature effect on THC synthesis depends on cannabis strain, gender, etc. 
Some authors have observed that K richer soil leads to lower THC production, although K-P interaction, N and Ca richer soil increases THC synthesis. Other authors report that Fe and Mg are important for THC production and they believe they are important for enzymes in THC synthesis. According to other authors there is a negative correlation between plant height and THC production – taller plants produce less THC. 
In summery: THC synthesis depends on plant genetics, environmental factors, growth conditions, strain morphology and characteristics.