Formal charge is a construct that helps us decide on the "best" structure when making attempts. Following the octet rule is very helpful and should be your first approach. But sometimes you can come up with two or more structures that both satisfy the octet rule and you're faced with "which one?". Often, one structure is the preferred and "right" structure. The right/correct structure is always the one with the smallest absolute values of formal charge. And, since zero is the winner of smallest, we say the best structure is the one with the most zeros in it.
Unfortunately, sometimes it is just impossible to get all zeroes for formal charge on a structure. This is when we allow both +1 and –1 as formal charges also. These are not only "ok" but also necessary on certain structures.
Now don't get carried away on drifting from zero. All other values are considered "bad". Do NOT ever consider a structure as valid or correct when any atom has a formal charge outside of the –1, 0, +1 range. So yes, I'm talking to you +2 and –2. You guys just don't cut it on structure. Avoid them like crazy. Stick to the sweet spot of formal charges. Zero is best, +1 and –1 are fine... +2, –2, +3, –3 are right out! Here's you a graphic to help.
First and foremost, know that formal charge is not a real charge at all - it is an electron counting inventory system that helps us decide on best structures. It can also help one better identify which atoms might be more positive or more negative in the structure.
Here is the touchy-feely method: Every atom has a core or kernel charge - it is the same as the number of valence electrons (the group number ignoring the 10's digit). So that is a positive number. Now you subtract one for every electron that "belongs" to that element. Both electrons in a lone pair belong to the element and no one else. Any bonding electrons are evenly split between the two atoms involved in the bond. So in methane where C is surrounded by 4 bonding pairs with a H on the other side, the kernel charge is +4 and then we subtract 4 for the four electrons that belong to carbon in the single bonds. That gives zero formal charge. The hydrogens all have +1 as the kernel charge and -1 for the one electron in the single bond that belongs to the hydrogen. That too, equals zero.
Now here is the more geeky, math-y, formula way to "calculate" formal charge. The formula for formal charge (\(FC\))is
\[FC = V - (L + S/2)\]
Where \(V\) is the number of valence electrons, \(L\) is the number of lone pair electrons, and \(S\) is the number of shared electrons. This is the same as the touchy-feely method but is more mathematical.
external links