Although the device is marketed as a "trigger safety," as Jeff Cooper pointed out with the Glock, putting the safety on the trigger is like putting the combination on the vault door.
One purpose of the device is, most assuredly, to help to prevent inadvertent discharge.
You will, however, note that for the most part such devices are only present on STRIKER fired pistols and not on hammer fired pistols.
The reason the device is ever present on striker fired pistols is because of the possibility of inertial discharge in case of a drop on the REAR (rather than muzzle) of the pistol.
Historically, engineers figured out that semi-autos could discharge if dropped on the MUZZLE as the only thing holding back the firing pin was the firing pin spring. A heavy steel firing pin, in combination with a spring that is worn, in combination with a drop onto the muzzle from a sufficient height results in a BANG.
Colt figured this out well before WWII and one of its engineers, William L. Swartz, filed a patent application on 4-13-1937. The so-called Swartz safety was patented on 12-20-1938, patent number 2,140,946. The device was licensed to Colt's Patent Fire Arms Manufacturing Company, Hartford Connecticut. The Swartz Safety was an internal firing pin block which was deactivated when the grip safety on the 1911 was depressed.
The device was put on some pre-war 1911s (I have seen it more often on .38 Supers), but it was expensive and WWII came along, and the device was not put into war time production, nor was it added back after the war.
The weak point of its design was that it worked off the grip safety. Some thought that was its strong suit. In any event, when Colt introduced its Series 80 improvements, things were getting less business friendly from a litigation standpoint, and so a device to prevent discharge was needed in case the 1911 was dropped. Colt re-designed the Swartz Safety into the Series 80 firing pin block we know today, which differs from Swartz' patent in that the Series 80 works off the trigger as opposed to the grip safety. It is a more positive system. It was initially criticized as making a light trigger more difficult to achieve, but the only place this rumor still persists is on the internet.
The Series 80 system patent ran out and now Remington, Para, Umarex and others use it. Kimber uses the Swartz system as did S&W on its original 1911s. S&W's new system, like Springfield and many others, now use a very light titanium firing pin combined with a heavy firing pin spring to survive drop testing. Colt uses this method on its Series 70 reproduction guns and anything that does not have the actual Series 80 firing pin safety.
The main purpose of the firing pin block is to prevent inertial firing in the event of a drop on the muzzle. The firing pin block was introduced to "modern" pistols with the West German police pistol trials in the 1970s, which produced the Walther P5, the SIG P6 (commercial 225) and the HK P7 (PSP, P7, P7M8, etc.).
SIG and Walther put the firing pin block into its designs, which were, in compliance with the West German requirements, designed to have no safety lever in the traditional sense. S&W's 1st Gen Autos had the P38 style safety, which decocked the pistol and arrested the firing pin when in the ON position (down). Designed to prevent inertial discharge in the safe position, NOTHING was present to prevent inertial discharge in the event the slide mounted safety of the S&W was in the fire position (up). Because it deactivated the trigger when on, the slide mounted safety/decocker, which was difficult to take off at high speed - much more so than the ergonomically better thumb safety lock on the 1911 - Jeff Cooper gave it the nickname "Dingus," leading to the Cooper dictum, "Don't get caught with your Dingus down."
As LE doctrine changed subsequent to the West German Police trials, agencies decided that the slide mounted safeties should be carried OFF, and S&W then designed its firing pin block into 2nd Gen and subsequent designs, including all current modern duty pistols (except the 1911 E Series, which uses the light firing pin method as explained) in order to prevent inertial discharge in the event the pistol was dropped.
Enter the striker fired mechanism. Glock knew that inertia works in both directions. A striker fired pistol in which a "trigger bar" is in contact with not only the lug on the firing pin, but also the firing pin safety, and which when drawn to the rear will hit a release point causing BOTH the deactivation of the firing pin safety and the release of the striker to run forward at high speed to fire the round presented a problem not present on hammer fired pistols.
Thus, something had to be designed into the system of the striker fired pistols which would prevent inertia from causing the trigger bar to travel rearward thereby deactivating BOTH the firing pin safety and causing release of the firing pin.
Because the pistol will discharge no matter what causes the striker to move far enough rearward, the extra device to prevent inertia firing was needed.
Inertia of the kind which can cause a discharge in the 1911 is normally thought of as a drop on the muzzle, the pistol stops suddenly, and the firing pin keeps moving forward. BANG. Certain rifles, such as ARs, AKs and M1As and M14s have this same issue. Slam firing is the term applied when the bolt runs forward on such a rifle at high speed, comes to a sudden stop, the firing pin keeps moving forward and the primer is dented. Usually not enough to cause a discharge, but if you have an extra sensitive primer, well - that is when your muzzle better be pointed in a safe direction. Some AKs for the US commercial market have firing pin springs designed to prevent slam firing.
Inertia works both ways. In a striker fired pistol, the firing pin safety prevents discharge if the pistol is dropped on the muzzle. However, if a striker fired pistol is dropped on its rear end, inertia can, and will, without the little articulating trigger, cause the trigger bar to keep moving to the rear. Of course, as it does so, the firing pin safety is deactivated and eventually, if the drop to the pistol's rear is with enough force, the trigger bar moves far enough back to its release point, and BANG.
In the event of a drop on the pistol's rear, there is no finger or anything else "pulling" the trigger, so the little articulating device does not get deactivated, and the whole trigger bar is not free to go flying rearward with inertia.
Now, all sorts of people will argue that it can't happen, the force is too great for an ordinary drop, etc. Not so. Please recall the Ruger SR9 was initially introduced without the articulating trigger safety. Very quickly, it was quietly redesigned and even the Ruger now has the device.
So, that is the real purpose of the device. Do you see why it is easier to merely call it a trigger safety? It would take pages of advertising to explain the above and few would understand it or care.
I hope that information was helpful.
EDIT: 8-7-2017
The SIG P320, just adopted by our military as the M17 and M18 pistols, seems to be the subject of a controversy.
Dallas PD stopped authorizing the pistols.
SIG and Dallas PD talked, concluded an officer misread or misunderstood a statement in a manual (perhaps an armorer's manual) and without any testing (apparently), SIG says all is well, and DPD is to resume authorizing the P320s.
Then, Omaha Outdoors drop tested the P320, and the results were so bad that Omaha Outdoors has suspended all sales of P320, at least as of the date of this edit.
See the following:
BREAKING: P320 Recall Issued By Dallas Police | Prohibited From Duty Till Repaired - The Firearm BlogThe Firearm Blog
Official Statement :SIG Sauer Reaffirms Safety of the P-320 pistol./ DPD Is In The Process Of Giving The Ok To Again Allow Officers To Carry The P-320. - The Firearm BlogThe Firearm Blog
And then, the Omaha Outdoors drop tests:
[ame]https://www.youtube.com/watch?v=ch7si_VQsGA[/ame]
EDIT 8-10-17:
SIG offers upgrade
BREAKING: Sig Sauer Offers To Upgrade P320 Pistols In Wake Of Drop Safety Failures - The Firearm BlogThe Firearm Blog
M17 and M18 already receiving upgrade
SIG SAUER Acknowledges P320 Trigger Issues With -30deg Drop, M17 MHS Unaffected, Announces Voluntary P320 Upgrade - Soldier Systems Daily