I can tell much about the issue in my country. However, I do not know if the same issue happens or not in US.
Most criminals in Indonesia are drug related crime. Drug is the most illegal things in US. My friend told me that you can do anything in Indonesia, even murder people, but don't do drugs ever.
Drugs, soft drugs, like xtc, meth, ganja, are freely available though. Everybody knows how to get it. Namely in most clubs in central Jakarta. Everybody knows that cops are paid to look the other way around.
This give some perverted incentives for cops. Cops that shoot down pickpockets and robbers go to jail. Cops that arrest drug users can demand $100k bribe.
Most people in Indonesia consider drug as "evil". There are huge population support in favor of death penalty for drug smugglers.
Back to questions. Why would legislators prohibit drugs?
If drugs were legal, whether it's taxed or not, the cops would not get money anymore. I am pretty sure the cops would put some good words for legislators to criminalize it. It's a very simple, very obvious motives.
Government here wants to control anything with high economic value. Every trade with high economic value is controlled in one way or another.
So not just drugs. Someone get caught for buying from farmers and selling chili to factories. The people just buy it because they think that the act would "stabilize prize". Prostitution is also controlled. Almost all massage parlor provides extra service.
In fact, it happens again and again and again in all sort of area of life. Cops would arrest a shop for selling without "license". Then another soap factories will be screwed for "not" having licenses. Then some merchants are arrested for "disrupting" price because the merchant engage in "unhealthy competition".
All those "criminals" are extortable. Cops that arrest them are rich. Cops that arrest real criminals got nothing.
Basically most cops here do not go after thieves, burglars or robbers. They aim for good people selling anything and find mistakes. Rules are unclear so anyone is guilty of something.
So I think that's the motive of why narcotics are illegal in Indonesia. However, I do not see how this extend to countries with less corruption. Narcotic is also illegal in Singapore and US. And that includes narcotics with minimum danger.
And that's actually what motivates the question.