When magnesium reacts with copper sulfate, the magnesium displaces the copper from the solution. This causes the blue color of the copper sulfate to gradually disappear as magnesium sulfate and copper metal are formed. The magnesium is a more reactive metal and so it replaces the copper in the copper sulfate compound.