why some elements have two valency?
Normally elements donate, accept or share electrons from/on their valence shell in order to attain a stable electronic configuration in its ultimate (valence) shells. In most of the cases driving force for such electron transfer/ share is attaining octet or next inert gas configuration in the valence shell. However, there are exceptions to this general rule too. Stable molecules with incomplete octet or expanded octet are known. In addition to that, it is not octet rule alone that dictates such transfer or share. Other factors sometimes come into play. Consider the case of iron, for example (electronic configuration [Ar]3d64s2). It has two electrons in its valence shell, so when it donates those two, the next shell (penultimate level originally) becomes the ultimate shell now, which has a pretty stable configuration. Logically two is a stable valency for iron. But, in this level there are d- sublevels, wherein this cation possesses 6 electrons. Half-filled/full filled rule tells that d˄5(or d˄10) system is more stable than its immediate neighbours. So if it loses another electron from that level, it attains another milestone of stability, hence 3 is another stable valency for iron. Similarly, for copper (...3d94s2), two valencies (1 as well as 2) are observed and explicable on similar lines. Sometimes another phenomenon, known as ‘inert pair effect’, makes room for such variable valencies in Sn and Pb, both of them showing 2 and 4 as stable valencies.