Actually, drug testing is a good measure of impulsivity and distractibility. If a person cannot manage to pass a drug test, they lack self control and are likely to do things like bitch out customers and break expensive equipment.
The self control aspect of drug tests are probably a pretty good proxy for IQ—ADHD is correlated with a substantial 10 point drop in IQ.
You could just as well test for salt consumption as cocaine. The point is to check whether the applicant can hold their shit together for a few days for something as important as a job.