The melting/boiling point of a substance determines what state of matter it takes at a certain temperature.
In Cl2 there are covalent bonds between the atoms forming simple molecules. There are weak attractions between molecules of Cl2 meaning little energy is needed to break these forces of attraction and therefore Cl2 has a low boiling point.
NaCl on the other hand has strong electrostatic forces of attraction between the positvely charged Na ion and the negatively charged Cl ion. NaCl forms a giant ionic lattice that requires high amounts of energy to break and therefore has a high melting point.