When electricity flows through a coil of wire, it turns into a magnet, an electromagnet.

That coil will now be attracted to the real magnets inside the cone.

Your music device will send out unique intensities of electric current causing the right vibrations that will vibrate the cone, that vibrates the air, that vibrate your eardrum, that we interpret as sound!”

Link