When cannabis or cannabinoid drugs are prescribed for cancer and AIDS patients, the reason is generally not the disease itself, but cachexia, the severe wasting disease that such patients often have to suffer with.
According to literature from the American Cancer Society, cachexia and anorexia (not the anorexia nervosa associated with teenaged girls) are diagnosed in more than two thirds of all cancer patients in the advanced stages of the disease. They are considered independent risk factors when calculating morbidity (the stage of the disease) and mortality (the likelihood of death.) Anorexia, nausea, and vomiting, in fact, are often described as being more detrimental to patients' quality of life than even severe pain.
In 1986, the main effective component of cannabis, delta-9-tetrahydrocannabinol (THC) was licensed as an anti-emitic (anti-nausea) drug for cancer patients undergoing chemotherapy. As well, clinical studies have shown that THC provides significant stimulation of the appetite and increased body weight in patients with AIDS (or who are HIV-positive) and cancer. Just as recreational pot smokers experience "the munchies," those who use cannabis for medicinal reasons find their appetites improved and gain weight.
Most research points to whole cannabis being more effective in treating cachexia and disease-related anorexia than THC alone, because of the other cannabinoids present, including CBD, or cannabidiol, which mitigates the psychotropic effects of THC, but don't prevent the appetite stimulating effect. Most clinical research, then, is involved in comparing the therapeutic effects of whole-plant cannabis extracts to those of dronabinol (THC) alone in controlled studies.
While most cancer and AIDS patients are not allowed to have medical marijuana prescriptions just for cachexia, in those states where cannabis is licensed for medical use, they are allowed to have it to relieve pain and alleviate other symptoms. At this point, the fact that it also helps combat cachexia and anorexia is merely a bonus.