It was already discovered by Ampere about 200 years ago, that if you had a magnetic field and a wire carried a current through that field, then that wire would feel a force on it proportional to the current in the wire, and proportional to the strength of the magnetic field. That force was in a direction perpendicular to the wire, and also perpendicular to the direction of the magnetic field.
Thus, in a dynamic loudspeaker, a wire is wrapped around a cylinder many times (to increase the force since each piece of wire will feel the same force since each carries the same current.) That cylinder is then immersed in a strong magnetic field ( Good loudspeakers use some of the strongest permanant magnets available). The amplifier then, by raising and lowering the voltage, drives more or less current through the coils of the loudspeaker, producing more or less force on the diaphram.