from what i remember from my A+ class, an UPS can function as a line conditioner buffering electricity both surges and dips, and also has a battery so you can save work and safely shutdown, UPS are used on servers to keep the server up long enough for a generator to start in a power loss, however, they cant stop lightning, the only way to prevent lightning damage is to unplug your computer from an outlet, and in some cases that doesn't even work, a non diffused strike withing 30-50 feet can still fry your CPU, which is why servers are not placed near an outside wall
this is why a good place to put your computer is in the basement, it's safer from lightning and often the cooler part of a house