With regards to the drug testing debate... Well most companies will tell you it's about health and happy employees. Most will say federal guidelines, company policy etc. Basically when you boil it down, it's the same as anything. Liability. They don't want the bad PR, they don't want to have money come out of their pockets. I'll use two very extreme, very fictional examples. Company A, let's call it Schmoeing... Schmoeing makes airplane parts for commercial and government contracts. Little Timmy is blitzed on ghost pepper nitrous shots, or whatever the kids are doing now'a'days, and his cuts on ginglymus #3 are half an inch out of spec. This results in a commercial airliner having a forced landing and an FAA investigation. Now, if Schmoeing didn't do drug tests? Senators and Congressmen would be on the news blaming their lack of principles and dragging them through the mud, jeopardizing the contracts and the entire company. But since they do, now they increase scrutiny for awhile, random testing becomes mandatory for a few months, everything dies down when one of the Kardashians sneezes and pushes the story out of the news, and everything can go back to normal where it's truly a random screen, and/or the company can use it to try to trip up some problematic employee and fire them for policy violation and not have to pay them severance or unemployment.
Company B. Grandma's Groceries, HVAC system has a vent and a fan that blows over a warm plate of oatmeal cookies for the proper ambiance while shopping. Billy has worked for Grandma for years, model employee. Billy does like his Sweet Chowder though (Cocaine and Sour dough, drug soup out of Boston y'know) but he is responsible and doesn't do it at work. However someone called out sick on Billy's day off and Grandma is in a bind so he wanted to help out. He gets the shakes at work and while he's stocking a shelf full of surströmming his shakes knock over a can and it lands on some ladies head, now she's going to sue the whole company. Grandma's now in trouble and her reputation is in the tank because her company hires no good, strung out hop heads and she doesn't test them all for the devils lettuce.
Basically, you're damned if you do and damned if you don't. Most companies simply have it as another possible tool in their legal bag of tricks for when/if something ever happens. This way blame can be shifted to the degenerate, drug using employee as opposed to the company itself.