Melting points depend upon lattice energy. NaCl and KCl have unit charge on their ions while MgO and BaO have two units of charge, therefore lattice energies of MgO and BaO are expected to be larger than those of NaCl and KCl. Since, Mg2+ is smaller than Ba2+, therefore, MgO has the higher lattice energy and hence, has the highest melting point.