The engines provide electrical and hydraulic power to the systems that control the flight path of the aircraft: elevator, aileron etc. If all power is lost, a Ram Air Turbine (RAT) is deployed which spins up and powers the systems from the airspeed. However, this creates extra drag.
The RAT deploys automatically upon loss of AC bus 1 and AC bus 2. This takes a while after engine fail since the engines spool down - if APU is switched on before the buses are detected down, the APU then powers the AC buses and the AC pumps that drive the Blue and Yellow hydraulic systems. Below 125 knots the RAT stalls.
The RAT was found deployed in the accident report. It has an automatic blade pitch adjust system that retains constant speed under load - if the RAT is deployed and needs to provide the backup power for Blue hydraulic and AC electrical, it extracts energy from the air stream and provides extra drag. If the APU provides power for electrical and hydraulic systems, the RAT windmills and there is less drag.
The A320 had just taken off and did not have much altitude yet. Aircraft without engine power can glide - the distance they can cover while gliding depends on the starting altitude of course, but also on Lift over Drag: the lower the drag, the further the aircraft can glide. Switching on the APU provided them with extra gliding distance due to less drag - although that may not have been the captain's main objective, it may have been an attempt at engine start.
They needed all the distance they could get, and all the clearheadedness that could be provided. And that is what the pilots delivered. Switching on the APU bought them time, and more choice in landing the plane at a suitable spot. The situation was not exclusively saved by switching on the APU, it was a factor in a chain of events where everything needed to be right - and it was.