To begin, I objectively have too many headphones for my own good (or at least my parents say so). So in lieu of Apple removing the headphone jack (for better, or worse), I figured I'd go over how the century old standard actually works on a digital system on the consumer side. Let's dive in.
01000010 01101001 01101110 01100001 01110010 01111001
It begins with the audio file. These audio files have a 'sample rate.' In standard (non-cinematic) consumer audio, the sample rate is 44,100 (or more commonly known as 44.1k) samples/second. These 'samples' are basically the pixels to the music. They are in essence tiny pieces of the waveform that, when together, make up the audio file. A massive oversimplification, but it gets the point across. Those samples are put through what is called a DAC.
DACs on DACs on DACs
DAC stands for Digital to Analog Converter. What this does is it takes those tiny digital bits and pieces, and puts them together to form a smooth analog signal. That low powered signal then goes to an amp.
Amplifier (It goes to 11.)
The analog signal is then 'amplified' to match the impedance of whatever speaker or headphone you are listening to. In essence, sending the electrical signals to your headphone/speaker drivers to make them have a loud enough sound.
Headphones (Fire up that loud! Another round of shots! Turn down for hearing loss!)
Then in headphone drivers (dynamic, not planar magnetic nor electrostatic) get the power from the headphone amp, in turn creating a magnetic pulse to the waveform of the music, resulting in the membrane pulsing back and forth, causing the air to move forward, giving it a sound.
If you want to know more about how headphones work, check out this link from Snazzy Labs!