The tube consists of a hot filament charged by direct current, built into a resonant cavity and the whole assembly placed in a magnetic field, which deflects the electrons boiling off of the filament, adding energy to the cavity. The charges in the cavity slosh around at its resonant frequency which for microwave ovens is 2.45 GHz, resulting in radiation with a wavelength of 12cm.
There was an urgent need during radar development in World War II for a microwave generator that worked in shorter wavelengths - around 10cm rather than 150cm - available from generators of the time. In 1940, at Birmingham University, John Randall and Harry Boot produced a working prototype of the cavity magnetron, and soon managed to increase its power output 100-fold. In August 1941, the first production model was shipped to the United States.
Since then, many million cavity magnetrons have been manufactured; some for radar, but the vast majority for another application that was completely unanticipated at the time - the microwave oven.