Sodium chloride has a high melting point because of the strong electrostatic attraction between its positive and negative ions; this requires more heat energy to overcome. All ionic compounds have high melting points for this reason.
The difference in melting points for ionic compounds can be explained by the size of the ions themselves; smaller ions are able to get closer, and this increases the strength of the electrostatic charge between them. Another factor affecting the melting point of ionic compounds is the number of charges on the ion. For example, magnesium oxide has a charge of +2 and -2, which is stronger than sodium chloride's ionic charge of +1 and -1.