Sweating causes the body to lose salt and moisture. If you do not have enough salt in your muscles, your muscles will cramp and cause you pain.