Octet rule – it states that atoms of elements are stable with 8 electrons in their outermost shell and they tend to undergo chemical changes ( losing or gaining electrons ) to get this structure.
Elements after these chemical changes attain noble gas configuration. Chemically active elements don’t have 8 electrons in their outermost shell and that’s why they lose or gain electrons to obtain stable octet structure.
Atoms having more than 4 electrons and less than 8 electrons, already in their outermost shell, tend to gain electrons thereby becoming negatively charged (anions). Atoms having less than 4 electrons and more than 0 electrons, already in their outermost shell, tend to lose electrons thereby becoming positively charged (cations). The ultimate result of this is obtaining octet in outer most shell.