Iron exhibits two different oxidation numbers in compounds, +2 and +3, which are seen in two different chemical compounds, FeCl2 and FeCl3, for instance. Stable compounds form because the products are at a lower total energy than the reactants. That is the case for both FeCl2 and FeCl3. But it is possible to cause the further oxidation of iron in FeCl2 to the +3 oxidation state, as in this reaction.2FeCl2 + Cl2 --> 2FeCl3 Transition metals show variable valency and these elements have d-orbital as penultimate orbital and the outermost orbital is the s-orbital.
Now, the atomic number of Fe, Iron is 26
The electronic configuration is
(1s)2 (2s)2 (2p)6 (3s)2 (3p)6 (4s)2 (3d)6 (aufbau's principle).
But the exact arrangement is also possible with (1s)2 (2s)2 (2p)6 (3s)2 (3p)6 (3d)6 (4s)2.
Therefore, because of the different electronic configurations which the element can have it shows variable valency.
Another reason: An atom has to complete 2 or 8 electrons in its outermost shell therefore, when Fe or any other transition element reacts with the other element then these transition atoms share the electrons according to their requirements
Eg: 1. Cu 1+ & Cu 2+
2. Ag 1+ & Ag 2+
3. Hg 1+ & Hg 2+
4. Au 1+ & Au 3+
5. Fe 2+ & Fe 3+
6. Pb 2+ & Pb 4+
7. Sn 2+ & Sn 4+
8. Pt 2+ & Pt 4+
9.Mn 2+ & Mn 4+