Carbon has four electrons in its outermost shell, and it is energetically unfavorable for it to either gain or lose four electrons to form an ion. Therefore, carbon shares electrons and forms covalent bonds.