It doesn't. A transformer works by magnetic induction between the two coils, it doesn't matter whether the secondary is loaded or not. The primary, if connected to a source of current, conducts just fine.
The alternating magnetic field, created by the primary is always present in the system and the induction happens even in an open secondary. It just doesn't do any work.
Unlike what PhysicsDave said below, adding a resistor just anywhere produces different results. Adding a resistor along the primary reduces the voltage, reaching the induction coil by dissipating some energy as heat. While adding a resistance or load along the secondary makes use of the energy rather than waste it in the case of resistor in primary winding.
Also opening the primary winding's circuit with the secondary unloaded might causes spark to jump across the switch, cause by backflow of current due to self induction of the primary.
Induction in a transformer is a bit tricky I'll say, when a coil is energized and a magnetic field is formed around it, this energy seems to be stored somewhere in space within the field as potential. This energy bank energizes the electron in the secondary winding.
Now, if the secondary is not consuming the energy and the primary circuit is also abruptly discontinued, what happens to the potential energy in the field and the energy in the energized electrons in the secondary winding? It's not in a form of energy that can propagate out into space - heat, sound or electromagnetic -, so if it can't flow outward, then it flows back inward. If self induction never happens in a case like that, then we'll have a cloud of energy floating around in 3D space, and any conductor in its path get toasted (I mean a human).