Why is doping illegal in Tour de France?
You have to draw the line somewhere. If you allow all doping, then the winner will be the one most willing to sacrifice their long-term health to use the most drugs and maximise performance enhancement. 


  Then why don't they simply limit the doping to forms of doping and medical treatments that have been peer reviewed and demonstrated to be relatively safe?


They do this to a certain extent. One of the three criteria for adding a drug to the banned list is that it represents a health risk to athletes. There are also some substances which are allowed up to a certain threshold. Asthmatics (and non-asthmatics if they feel like it) for example are allowed to use a salbutamol (ventolin) puffer, but if an unreasonable amount of salbutamol is detected, then it is deemed as being a performance enhancer instead of being used for health.

The two other criteria for banning a drug are about fairness. They are "If the substance is performance enhancing" and "If the substance violates the spirit of the sport". If a substance meets two of those three criteria, it can be added to the WADA list of banned substances. You can read more about this here.