This is a LONG answer — the question hits home on a classic example of the English language’s tendency for exceptions. It causes lots of confusion even for native speakers. Both forms are grammatically correct (contrary to the insistence of some British grammar purists). The first one (“What happened?”) is the one most of us would likely ever to need in normal life. The short practical answer:— Use “did” when we knew something had happened but wanted more details. In other words, treat “did” as an emphatic to express some kind or level of surprise, shock, disbelief, doubt or need for confirmation. It’s like, if that didn’t happen, what actually happened? The short technical answer:— The structure depends…