There's a tendency by main group elements in achieving 8 valence electrons or a filled outer shell, but undergoing chemical reactions. Main group metals lose electrons to be like the noble gas that is before them in the periodic table. For example, let's say that we're dealing with the sodium atom. Sodium has an atomic number of 11. The noble gas that came before it is neon, which has an atomic number of 10. So sodium wants to lose 1 electron so that it has the same number of electrons as neon, 10. Main group non-metals, however, tend to gain electrons to be like the noble gas that is after them in the periodic table. For example, let's say we have sulfur. Sulfur has an atomic number of 16. It wants to be like the noble gas that comes after it, which is argon. So sulfur would want to gain 2 electrons, and in that way have 18 electrons just like argon. Now why are they doing this? Well, they do this in order to create totally filled s and p subshells because this will lead to greater stability and help to lower further chemical reactivity.
So if we take a look here, we have lithium and fluorine. Lithium here is s 2 2 1 . Here, this electron is in its outer shell, so that's why it's being shown there. This is its outer shell electron. Fluorine is s 2 2 2 p 5 . It has this as its 2nd shell electrons because they're both 2, so in total, that's 7 electrons. Lithium wants to lose 1 electron so that its s subshell is completely filled because remember, s can hold a maximum of 2 electrons. Doing this gives it a similar electron configuration as helium. Fluorine gains that one electron that came from lithium, and when it gained that electron it becomes negative. But more importantly, when it gained that electron, it went to this p subshell. So now it's p 6 . Remember, p subshells can hold a maximum of 6 electrons, so now it's completely filled too. Doing this gives it a similar electron configuration to neon. So now both of my original elements have been turned into ions that have similar electron configurations to their noble gases near them. This is the whole point. This is what they want to do. Noble gases are very stable because of their filled outer shells, and doing this allows lithium and fluorine to mimic those noble gases.