A diet high in sugar contributes to the loss of nutrients like calcium, potassium, and magnesium, which helps regulate relaxation and contraction in muscles. When muscles are constantly contracting (muscle spasms), they become tense and tight which means a greater risk for aggravating nearby nerves.