Although some weird things have happened at the fringes, the real reason the drug war exists is simply that politicians believe that drugs and DRUG USERS are bad for society. The latter part, 'dangerous drug users', is where things get a little strange. Historically, the drug war has been a tool of racial and cultural oppression as well as a simple public health matter. Marijuana was outlawed during the Great Depression when white southerners feared losing already scarce jobs to competition from hispanics. Cocaine was outlawed when it became associated with the rise in prominence of black jazz culture. Every psychedelic the government could think of was outlawed in about 1970 during the height of the Hippie movement. Crack became the national menace when the press started frothing at the mouth over 'crack crazed blacks' in the inner city. (Interestingly, a white person is twice as likely to be a crack user as a black person.)
Over the years the American drug war has become more 'medicalized', focussing on public health as its justification, but still also has very strong roots in the puritanical idea that altering your mind is in of itself inherently wrong and a threat to society.
People that think the drug war exists to fund the CIA or make money for prisons are at best being overly simplistic; while these may at times have been motivation for some people, the vast majority has supported the drug war because they believe drug users are immoral and a danger to the public. And in some cases, they're even right.