This is a great question! I’d say that the reason is to actually protect the athletes, rather than protect the “purity” of the olympics. If they changed the rules so that people could do all the drugs they wanted to, then it would basically mean that you’re required to do drugs to effectively compete - those without the drugs would have a big disadvantage against those who use them.
We know that many performance enhancing drugs can have very harmful side-effects, so that would ultimately lead to athletes harming themselves to be able to compete.
That would not be a good outcome for anyone, I don’t think.