The definition of organic chemistry is rather arbitrary and sometimes it is just a matter of opinion. However, the widely used definition says that :
Organic chemistry is defined as the study of carbon compounds containing usually hydrogen and one or more additional elements like oxygen, nitrogen, halogens and phosphorus etc.
Inorganic chemistry is defined as the chemistry of all elements other than carbon and their compounds.
Even though CO, CO2, H2CO3, metal carbonates, cyanides etc., contain carbon, they are studied under inorganic chemistry due to their resemblance with inorganic compounds.
Whichever definition of organic compounds you want to use, directly or indirectly they all say that an organic compound must contain at least one carbon.
The catenation property and tetravalent nature of carbon enable it to form structurally diverse compounds.
The ability to form longer chains by linking to atoms of the same element is known as catenation.
3 carbons are linked together to form propane
6 carbons are linked together to form hexane
The atomic number of carbon is 6 and its electronic configuration is 1s22s22p2.
2 unpaired electrons in carbon atom
In its excited state, one paired electron from orbital '2s' becomes unpaired and jumps to the '2p' orbital without consuming excessive energy.
Excited state of carbon
Now, carbon has 4 unpaired electrons.
Clearly, carbon has four unpaired electrons in its excited state and needs four more electrons to be stable. It is very difficult for carbon to either gain or lose four electrons to achieve the nearest inert gas configuration. Thus, carbon always combines with other atoms by mutual sharing of electrons and forms four covalent bonds.
Note : The energy required for the excitation is compensated by the release of energy due to the formation of new compound.