What is the "yaw damper"?
The yaw damper is, in simplest terms, an "autopilot" for yaw. When engaged, it operates the rudder (or whatever yaw control method is available in exotic aircraft, like the B-2 flying wing).

Its primary goal is to counteract the typical Dutch roll aerodynamic mode of many aircraft. It also helps keep turns coordinated by automatically providing the necessary rudder inputs to avoid slipping/skidding in a  turn.

In normal aircraft the yaw damper is part of the automatic flight control system (AFCS) or "autopilot." It can usually be engaged on its own without the rest of the autopilot. On the other hand, most autopilots require the yaw damper to be engaged when the rest of the autopilot is engaged (you can have yaw damper without autopilot, but not autopilot without yaw damper).

For large / transport aircraft, the yaw damper is usually engaged throughout the entire flight profile except for takeoff and landing.

It is required equipment (link is to FAA certification regs but similar regs apply elsewhere) in many (most?) transport aircraft, which tend to suffer Dutch roll instability, but flights can sometimes still be made if the yaw damper is inoperable per the minimum equipment list (MEL), with restrictions. This depends on the exact aircraft type and any extra operator policies (company rules). Note that usually an inoperable yaw damper also precludes the use of the rest of the autopilot.

Modern digital yaw dampers are part of an integrated digital autopilot system. They use accelerometers and rate sensors to determine the aircraft's motion. It then runs the numbers through special algorithms to determine what rudder inputs need to be made in order to damp any Dutch roll and to coordinate a turn. It then provides those rudder commands to a servo or hydraulic system which operates the rudder.