Octet rule is a theory of chemical bonding. Chemical bonding exist because atoms "want" to be energetically stable. It was found that the atoms of Noble Gases are stable, and generally they don't have to make bonds to be highly stable. This is expressed by the electronic distribution, in which you see that Noble Gases atoms have filled orbitals, like 1s2 2s2 2p6 (Neon), and this is a reference of stability, as Neon atoms exist without bonding with no other atom. Atoms like Carbon have electrons distributed in 1s2 2s2 2p2, therefore they are not stable as Neon, and they must form bonds to be more stable.
The way Carbon forms bonds with hydrogen is called covalent bonding, and they "share" electrons. Carbon has its 2s2 2p2 electrons shared with 4 hydrogens, and 1 electron of each hydrogen is shared with carbon. Now, Carbon has 8 electrons in its valence shell, it reaches the configuration of Neon,
and is much more stable now. This theory works fine for many atoms, however fails to others. When you study the Transition Metals complexes, you see that they don't follow this rule. Then, there are more advanced theories that were proposed to explain them.
Please, reply if this explanation fits answers your questions, and feel free to ask about anything.