Because a clearance requires you to have discretion and control of yourself to maintain the secrets you learn due to it.
If you lack the self-control to not use a federally illegal drug on camera, then do you have the self-control to not leak secrets to score points in an argument or if you're drinking with a friend and they apply some social pressure, for instance? Maybe, maybe not, but it raises red flags about how trust worthy you are.
The reason I was told by someone who applied for security clearance is because it's a crime (federally) and they are afraid that someone could use that to blackmail you into giving state secrets.
I think it's a similar thing for illegally downloading music or whatever..
At least they should. I guess Musk plays by different rules than us plebians.