The electrical code, and the building codes in general, are not laws that are always in effect - they are regulations that a new or remodel project needs to meet at the time it is installed. An installation that is code compliant when installed does not need to modified in the future if the code changes, unless there is a remodeling project that goes through the building code process, then only the parts of the existing installation that interface with the new part are required to be changed. The legal mechanisms used to adopt building codes do not allow for the codes to be applied retroactively. Some people refer to this as grandfathering in the existing installations. This isn't technically true but it's basically the way it works in practice.
If you have a two wire circuit and part of the insulation on the hot wire fails a metal appliance or tool enclosure can be energized and have a 120v potential to ground. Since there is no ground wire this does. It create a short circuit so the breaker doesn't trip and an electric shock is waiting to happen. Connecting all of the metal parts of electric appliances together with ground wires, then connecting the ground wires to the system neutral at exactly one point provides a much greater likelihood of a breaker or fuse operating when a fault occurs, which has significantly reduced the number of people getting electric shocks.
The other subtlety is that this interconnected system of equipment grounds needs to be connected to the system neutral at exactly one point. This may be in the service entrance panel, in the meter base, or if the facility owns the transformer the neutral to ground bond is often made in the transformer. Connecting the neutral to the ground in more than one place is arguably safer than not having the ground connected, but it often results in steady state current on portions of the grounding system, which can also cause electric shocks.
Sent from my iPhone using Tapatalk