To swap parts, of course!
Most figures consist of two kinds of plastic. ABS is the rigid plastic, usually found in torsos. PVC is more flexible, usually used for heads and limbs. (None of this is true across the board on every figure.) The idea is to soften the PVC in order to separate parts.
If you’re swapping parts made of swivel joints, such as old Hasbro or Mattel animated figure, save yourself some trouble and just slice off the parts and replace the joints with magnets.
If you’re dealing with ball-and-socket joints, hair dryers come in handy in that you can heat up a targeted area, and then the joint may easily pop apart. (I use this method on the Bombshells all the time, especially since many of their parts are compatible between figures.) I’ll apply the heat for about 30 seconds, and then give a firm tug on the part to be removed. Be careful, as you run the risk of stretching the peg. If that starts to happen, stop, and re-evaluate. If it’s going to work, it will likely work well. If it’s not, you’ll know pretty quick.
When it’s time to re-join the parts, I again heat up the target area, usually the piece with a hole for the peg. You want the target area to soften under the heat, not the peg. Simply insert the peg into the target, and you should be good. (If it’s going to work at all.)
I recommend this method over boiling as it doesn’t harm the over structural integrity of the plastic as much, there’s no discoloration, and it’s a lot less messy.