The Octet rule is essential to obey nature's law of stability. Among all the elements in the periodic table, the noble gases in Group 8 are the most stable in. Hence, all the other elements aim to achieve their electronic configuration. So, all elements must bond with others to conform to be a part of group 8.
Bonds for non metals = 8 - Group number
Ex:
Bonds for oxygen = 8 - 4 = 4
Bonds for nitrogen = 8 - 5 = 3