MgCl2 = magnesium chloride

FeCl3 = Iron chloride

why is cl on one with a 2 and on the other with a 3

Thanks

Becasue Mg and Fe are capable of donating different numbers of valence electrons to the chlorine atoms.