To understand why this, and other ionic compounds have such high melting points, you have to understand the difference between ionic and covalent compounds.
In a covalent compound the bonding between the elements takes place because there is a sharing of electrons between the elements involved in the bonds. Covalent compounds exist as discrete molecules with little or no intermolecular attraction between the molecules and can move relatively freely in relation to one another. Thus molecules such as methane (
CH4), CO2, and larger molecules such as fats and oils are either liquids or gases at room temperature or will readily melt with the addition of heat energy.
Magnesium chloride is an example of an ionic compound. That means it is composed of a positive magnesium ions which has lost two electrons and two chlorine ions, each of which has gained one electron.
Ionic compounds do not exist as individual, discrete molecules but rather as a network if ions bonded to one another in a crystalline structure. Because the bonds between charged ions is very strong, and because the ions are in a fixed, crystal network, it takes a large amount of energy to break enough bonds to actually begin melting.