Zinc has the electronic configuration 3d10 4s2 and magnesium has 3s2
Now, chlorine (Cl) needs one electron to complete its orbit. Hence metals react with Cl easily.
In case of zinc, it is easier to attract an electron from the outermost shell since as we go away from the nucleus the force of attraction between the outermost electrons and nucleus decreases. So, it is easier to attract the electron in 4th shell.
Whereas in case of magnesium, the outermost electron is in 3rd shell so it is difficult to attract that electron in comparison to zinc hence one has to need magnesium while zinc reacts directly with chlorine.