In "what happened", "what" is the subject of the sentence. In "What did you do last night", a different word acts as a subject. I guess that is the reason.