Scientists aren't sure what causes nighttime leg cramps, but it's probably related to muscle fatigue and nerve damage. Stretching and massage can help.