Carbon has to either give or gain four electrons to achieve noble gas configuration and become stable.But it is difficult to gain or give four electrons.This is because
it cannot gain 4 electrons to become stable by attaining neon gas configuration as there will be a lot of resistance to put 4 electrons in its shell.And it can neither give four electrons to attain helium gas configuration and become stable as large amount of energy would be required to remove four electrons from the carbon atom
Thus carbon can neither gain nor give four electrons.The only way it can become stable is by sharing its valence electrons with electrons of other carbon atoms or atoms of other elements i.e. it forms a covalent bond