Why did Plague doctors wear those strange masks?

Plague doctors wore those strange masks primarily to protect themselves from the deadly diseases they were exposed to, particularly the bubonic plague. The masks had a beak-like shape which was filled with aromatic herbs, spices, flowers or vinegar-soaked sponges to filter the air and purify it before it entered the mask. The mask also had glass or crystal eyepieces that provided the doctor with a clear view of his surroundings. The long black robe and gloves were also meant to protect the doctor's whole body from infected material.