Since smoking drugs (like weed) can really alter your thinking process/decision making process, a lot of people use "What were you smoking?" as a way of saying, "What was going on in your head when you made this decision?"
It is a negative expression. It essentially means, "What the hell is wrong with you?"