The modern single-handheld bee smoker was invented in 1875 by Moses Quinby, the first commercial beekeeper in the USA. Quinby's device, with a bellows attached to a tin burner, vastly improved previous methods of blowing smoke onto beehives, a practice that has gone on since the ancient Egyptian civilizations, and probably even earlier.
According to Wikipedia:
The fact that smoke calms bees has been known since ancient times; however, the scientific explanation was unknown until the 20th century and is still not fully understood. Smoke masks alarm pheromones (which include various chemicals, e.g., isopentyl acetate) that are released by guard bees or bees that are injured during a beekeeper's inspection. The smoke creates an opportunity for the beekeeper to open the beehive and work while the colony's defensive response is interrupted. In addition, smoke initiates a feeding response in anticipation of possible hive abandonment due to fire. When a bee consumes honey the bee's abdomen distends, making it difficult to make the necessary flexes to sting. (The latter has always been the primary explanation of the smoker's effect, since this behavior of bees is easily observable.)
Smoke is of limited use with a swarm, partly because swarms have no honey stores to feed on. It is usually not needed, either, since swarms tend to be less defensive as they have no home to defend, and a fresh swarm will have fed well at the hive it left behind.
Remind me to get around to inventing a musical bee smoker that plays like a miniature squeeze box/concertina when the bellows are pressed.
(Pictured above: a Steampunk bee smoker from Dreadnought Designs)