A primary reason, aside from weight considerations, is - a gas turbine APU has a built in air compressor - the compressor stage of the turbine. As such, it can supply air under pressure, or bleed air, just as the main engines can.
Bleed air is used for several purposes on an airliner. It is used not only to pressurize the cabin while in flight, but also serves as an air conditioner or heater, as the climate dictates. The APU can operate the climate control system on the airliner when the main engines aren't running.
Bleed air is also used to start the main engines. One running engine can start all of the others - the main engines have a small turbine that uses the pressurized bleed air to spin the main turbine up to starting speed. Or... the APU can also supply that bleed air. It is not uncommon to use bleed air from the APU to start the main engines, such as when an airliner has shut down its engines while waiting on the taxiway due to extended delays.
In some cases, APU bleed air may be the only option: BA flight 9 used APU bleed air to restart its engines, when all four had been disabled by volcanic ash.
So one reason gas turbine APU's are used on airliners is - they can supply the bleed air that is used for several purposes on the airliner, when the main engines are not runnig.
A diesel generator would have to power a separate air compressor to do the same, and that's more weight, and another thing to break or need service.