Boiled down, the telephone can do two things simultaneously:
(1) Convert speech (sound waves) into an electrical signal than can travel through wires.
(2) Convert that electrical signal back into audible sound waves.
The first component is a microphone in the mouthpiece.
The second component is a speaker in the earpiece.
Both are examples of transducers -- devices that convert electrical energy to/from mechanical energy.
Alexander Graham Bell figured out how to make both kinds of transducers.
Then he connected two sets by long wires and applied a DC voltage from a battery. Modern telephones (land lines) still do pretty much the same thing.