It often relates to stress during the day and to chronic tightness in the muscles of the jaw.
A dentist can provide a simple splinting device which allows the muscles to relax and prevents the grinding.
Chronic night time teeth grinding can lead to problems with the joint of the jaw (called the TMJ or tempero-mandibular joint)
Hope that helps