The Glock design has two internal safeties that absolutely prevent the gun from discharging. One (the firing pin safety) blocks the firing pin from moving forward far enough to contact the primer unless the trigger is pulled. The second (the drop safety) holds the firing pin immobile from the rear until the trigger is pulled.
Both of those safeties rely on the trigger bar NOT moving unless the user intends to fire the gun.
The trigger safety is what locks the trigger bar into position and allows the other two safeties to do their job in the event the pistol is dropped or otherwise subjected to a sudden severe shock.
In addition to locking the trigger bar, the trigger safety, in conjunction with a wider than typical trigger guard is designed in such a way as to make trigger snags much less likely. The trigger safety takes up about 13% of the trigger face area leaving approximately 87% of the trigger face that can be bumped or pressed without the trigger being activated. A snagging object must contact the lower center portion of the trigger and stay in that position. If the snagging object rides up the trigger curve as is the tendency, it will stop against the frame where the trigger safety can not be disengaged. If the snagging object catches the edges of the trigger it can not disengage the trigger safety.
The trigger guard is also wider than typical, providing more overlap on both sides of the trigger, which means that a snagging object is more likely to be deflected away from the trigger. A comparison between the Glock 17 and the Beretta 92, for example will reveal that the Glock trigger guard overhangs the trigger on each side by about twice the amount that the Beretta 92 trigger guard overhangs the 92 trigger.
The Glock trigger safety is well thought out and works well. Like any other design it has advantages and disadvantages, proponents and opponents. For those who don't care for the philosophy behind it, there is a wide variety of other pistols with different safety design philosophies. One need only avoid the Glock offerings and the ever more numerous designs which have copied the general Glock safety philosophy.