According to this list of drug slang terms from a declassified DEA report, 51 is slang for crack cocaine.
Checking Green's Dictionary of Slang confirms the term (listed as fifty-one) and lists the etymology as unknown. However, I noticed that GDoS has an entry for "5150":
(US black/prison) someone in need of mental health treatment; an eccentric, a crazy person.
[police code, an insane person is annoying the public]
Is there any evidence of a potential relationship between the slang 5150 meaning "an eccentric/crazy person" and 51 meaning crack cocaine or tobacco laced with crack cocaine? Are there alternative theories?
The only alternative explanation I found is on Urban Dictionary; I can find no reputable source to back it up, and in fact, it even has a low rank on UD so I mention it only as a possible starting point for investigation:
a joint with $1 worth of weed and $5 of freebase.