When most people think of doctors, the first part of the visual is either the stethoscope or the lab coat. While doctors are not the only profession that wears lab coats (scientists in a lab often do too, for some of the same reasons), it is most strongly associated with medical settings. Interestingly, however, that crisp, white lab coat is a relatively recent addition to the doctor's tool kit, but it is one that has a great deal of importance now.
The doctor's wardrobe hasn't always included the lab coat. It hasn't even always been white. Years ago, when bloodletting was a more common medical treatment, doctors wore black. This was a practical choice since black would hide blood stains and other contamination well. It was also a stylistic choice, intended to visually signal the importance and somberness of the profession and remind people of their mortality. As knowledge of germs and the importance of cleanliness grew, however, the medical profession need a different look. Black could hide stains but it could also hide germs. Instead, hospitals (with their bedding), nurses, and eventually doctors traded the old fabrics for new, fresh, white ones, which would clearly show any stains or dirt.
Safety and protection was a huge part of switching to white, but it is also a major benefit to the lab coat in general. As an overcoat, the lab coat is a protective layer. It protects people from cross-contamination of bacteria. It protects the wearer's arms and torso from hazardous material, and in the event of a spill, it is easy to take off (without going over the head). Finally, the lab coat is usually a poly-cotton blend, which is flame-retardant and resistant to chemicals, offering further protection for the wearer.
Remember in the beginning when we said people strongly associate lab coats with doctors? Well, it's true. So true in fact that people are unconsciously more inclined to listen to a doctor who is in a lab coat than someone who isn't, because the coat itself signals professionalism and authority. This can have the added effect of boosting the mental wellbeing and productivity of the doctor wearing the coat as well.
Finally, lab coats are a simple and easy choice for medical professionals. It removes some of the work of deciding what to wear everyday in order to look professional. The lab coat accomplishes this on its own, because it is what the average person expects to see when looking at a doctor.