A yaw damper is used to prevent the aircraft from going into a dutch roll.
If, for some reason (wind gust for example), the aircraft slips (i.e. it turns without rolling: the aircraft's nose doesn't point to the direction of flight anymore), then, because of that turn the speed of the airfoil around the wings is not the same anymore (for a short while). One wing will generate more lift than the other and the aircraft starts rolling. At the same time (when the aircraft is turning) the entire vertical stabilizer catches wind, forcing the aircraft in a turn in the other direction.
The aircraft will of course not stop turning at exactly zero degrees yaw, it will go a bit further and the other side of the vertical stabilizer will start catching wind, the other wing will start generating more lift... The process starts all over again and this, COMBINED with the pilot's corrective actions could result in a uncontrollable situation. This is also commonly referred to as "pilot induced oscillations".
What a Yaw damper consists of physically, I don't know. I guess it is some electronic control unit (in the case of Airbus FBW certainly) that limits the deflection of the rudder. Maybe there's a hydromechanical coupling as well.
I know it might sound complicated, it is just not easy to explain (and understand) without the aid of a figure or drawing.
Hope it gave you something of a clue anyway...