There's a tendency of main group elements to achieve 8 valence electrons or a filled outer shell by undergoing chemical reactions. Main group metals lose electrons to resemble the noble gas that precedes them in the periodic table. For instance, consider sodium, which has an atomic number of 11. The noble gas before it is neon, with an atomic number of 10. Sodium wants to lose one electron to become just like neon. Conversely, nonmetals tend to gain electrons to emulate the noble gases that follow them in the periodic table. For example, chlorine has an atomic number of 17. It would need to gain one more electron to be just like the next noble gas, which is argon. This relationship between nonmetals, metals, and noble gases emerges because they aim to create completely filled energy levels, which leads to greater stability and lower chemical reactivity.
If we analyze the situation with lithium and fluorine, we find that lithium has one valence electron as its outer shell electron, with the electron configuration 2-1, signifying it solely possesses one electron in its second shell. In contrast, fluorine has seven valence electrons 2-7. Lithium, belonging to group 1A, aims to lose one electron to attain a +1 charge. This electron loss results in lithium having a filled outer shell, mirroring the electron configuration of helium. The electron transferred from lithium does not disappear; instead, it is acquired by fluorine. By accepting this electron, fluorine acquires a filled outer shell, the electron configuration becoming similar to neon, resulting in an ion commonly referred to as fluoride. This exchange illustrates the essence of the octet rule where atoms either gain or lose electrons to resemble the electron configuration of the nearest noble gas.