A small clinical study including only 10 patients found that magnesium improved insomnia related to restless legs syndrome (a disorder characterized by uncomfortable sensations in the legs, which are worse during periods of inactivity or rest or while sitting or lying down).