Carbon's atomic number is 6, so it has 6 electrons. Its ground state configuration is:
1s22s22p2
The second energy level can hold 2 electrons in the s shell and 6 in the p shell, for a total of 8 electrons. Carbon has 2 in the s shell and 2 in the p shell, a total of 4. Hence the valence shell (2nd energy level) in carbon is exactly half full. This is what accounts for carbon's ability to form so many stable compounds.