I'm sure it's like any painkiller - different ones work on different types of pain, and it will depend on how your pain manifests.
Cannabis is a vasodilator (which is why people's eyes go red) so if the pain is muscular, it might help somewhat via general relaxation and increased blood flow. I've read that THC actually *would* be a good remedy for asthma since it can relax and open the bronchial tubes, but smoking it essentially negates the effect.
If your pain is due to bone or nerve problems, cannabis may not work in a way that can relieve it. Similar to various other painkiller types. It's possible some people who use it for pain may just benefit from being zoned out and more capable of mentally dealing with it.
It helps with nausea in many people, but for a certain unlucky few it causes nausea. It commonly causes "munchies" increased appetite which is a good effect for cancer or AIDS patients. Myself, I don't get munchies. I've cooked an entire elaborate meal for other people while high and then just not been in the correct mood to to eat any of it myself for hours afterward.