The valency of an element is the number of electrons it gains or loses or shares to attain the noble gas configuration. ... Also note that the 3d orbital has 1 electron pair, rest of the electrons are unpaired. Now,iron exhibits 2 valence states of +2 and +3. When iron loses the 2 4s electrons, it attains a valency of +2.
Sometimes, iron will also lose one of the paired electrons from 3d orbital, leaving the entire 3d orbital filled with unpaired electrons (which provides a more stable configuration). In this case, its valency will be +3.