The color of copper sulfate solution changes when an iron nail is dipped in it because of a displacement reaction. Iron is more reactive than copper, so it displaces copper from copper sulfate. This reaction forms iron sulfate, which is green in color, replacing the blue copper sulfate solution color. The chemical reaction involved is:
Fe (s)+CuSO4(aq)→FeSO4(aq)+Cu (s)\text{Fe (s)}+\text{CuSO}_4\text{(aq)}\rightarrow \text{FeSO}_4\text{(aq)}+\text{Cu (s)}Fe (s)+CuSO4(aq)→FeSO4(aq)+Cu (s)
As iron dissolves into the solution forming iron sulfate, the blue color of copper sulfate changes to green due to iron sulfate's presence.