I'm not sure that's an apt example. Ecstasy and penicillin are both final derivative products of some synthesizing process.
One is greatly beneficial, while the other is of very questionable value. Tiny doses of one can cure disease, while tiny doses of the other merely intoxicate.
I don't now if it's possible to derive a beneficial compound from MDMA, which is itself a derivative. What these 'scientists' are doing is directly administering MDMA as a treatment.
Agree with all you said .... my point was that you just never know what’s around the corner.