It is because the earth's magnetic field is in North-South direction and this retards the blood flow through brain capillaries and affect the functioning of brain cells.
Our body can be considered as a magnet with the head representing its magnetic north and feet representing its magnetic south. When one sleeps with head in South, magnetic fields from the head go towards to south of the earth and enters from the earth's north to the feet thereby forming a magnetic loop. This happens because in Magnetic theory, Opposites attracts and Likes Repel.
While when a person sleeps with his head facing the north, magnetic field of the body and earth are not in harmony and this results in the disturbed blood circulation resulting in mental unrest and a disturbed sleep.