This is a so-called “telegraph key” – a device that fundamentally changed the way people communicated in the 19th and 20th centuries. It was used to transmit messages in Morse code via electrical impulses sent through wires, or later by radio.
The key allowed the telegraphist to manually “key” (connect and disconnect the electrical circuit). This created short and long signals – dots and dashes corresponding to Morse code characters. It’s just like pressing a computer mouse button: a short press is a dot, a long press is a dash. By combining short and long presses, the operator “writes” a message, which the receiver then decodes (translates) into regular letters and words.
From 1844 (the first public use of the Morse telegraph) until the mid-20th century, the telegraph key was the primary tool for long-distance communication… because it was reliable, simple, and inexpensive. Telegram transmission was commonly used between post offices, railway stations, military units, as well as in the navy, and later among amateur radio operators.