Extracting and purifying a chemical is quite easy once you know the structure and the properties of the chemical. I'm not surprised it's been isolated and put in pill form. It's relatively simple organic chemisty at a crude level.
It's likely that it isn't just one gene that codes for 'it', unless it's a protein and I seriously doubt it is. If anything it would probably be a secondary metabolite produced in a metabolic pathway. Biochemical groups such as the terpenoids are often produced via these metabolic pathways and are multi-step processes which require many enzymes to go through the transition stages. You're not going from A to B. You're going from A to C to D to E...to B
It's likely that a fair few genes are required for the expression of the enzymes. It's probably possible to genetically engineer the genes into a bacterium such as
E.coli and mass produce the stuff. Just like insulin. It would be much harder to introduce the gene into another plant though.
As for research, I'd imagine that despite the stigma attached to it, THC probably has quite a bit of research done on it and more still as it has been shown to treat certain medical ailments.