The theory was sketched in Lord Shaftesbury’s 1709 essay “An Essay on the Freedom of Wit and Humour,” the first publication in which humour is used in its modern sense of funniness. Scientists at the time knew that nerves connect the brain with the sense organs and muscles, but they thought that nerves carried “animal spirits”—gases and liquids such as air and blood. John Locke (1690, Book 3, ch. 9, para.16), for instance, describes animal spirits as “fluid and subtile Matter, passing through the Conduits of the Nerves.”
Shaftesbury’s explanation of laughter is that it releases animal spirits that have built up pressure inside the nerves.
He wrote: "The natural free spirits of ingenious men, if imprisoned or controlled, will find out other ways of motion to relieve themselves in their constraint; and whether it be in burlesque, mimicry, or buffoonery, they will be glad at any rate to vent themselves, and be revenged upon their constrainers."
All of the above via https://plato.stanford.edu/entries/humor/#RelThe