The drug laws started getting passed when they became a problem, for instance Opium in San Francisco.
Just as polygamy wasn’t a problem, until it became a problem, and the same reason that we are now having to look at laws banning full term abortions.
The only "problem" in San Francisco was that Chinese laborers were indulging in recreational substances different from the ones the Caucasian majority favored.