Ground is "protective earth". Its purpose is so that, if a conductor (especially a live mains conductor) should come loose inside the equipment (or outside of -- even for the wiring in the walls, in the case of metallic conduit or metal studs), it is extremely likely to touch metallic ground well before anyone can get a finger near enough to receive a shock.
Shunting the AC line therefore serves to blow the fuse in the equipment, de-energizing it and making it safe (both against shocks and starting fires -- hopefully).
Internal circuits don't need to be grounded, but it can help.
Example: a desktop CPU is built inside a grounded enclosure. The SELV DC outputs (+12, +5, etc.) are grounded. Why? If a conductor comes loose and contacts the case, instead of potentially applying -12V (or whatever) to everything else in the circuit, it shorts out the power supply. (Which is typically designed to shut down safely in this event, but could be a fused type instead, for the same operation as the mains case.) The voltage is not a hazard (SELV is under 50V), but the available power could be (>20A through a single wire, or a few strands of one, could cause an internal fire I suppose).
One case that is required: draining ESD. Suppose someone walks up to the equipment, it's a cold, dry winter's day, and there is carpet in the office. Zap. Where does the static charge go? It generally has to be sunk into a safety-grounded circuit, sooner or later. Otherwise dangerous voltages could accumulate on human-touchable surfaces, or internal breakdown could occur. There are different methods, such as direct grounding, capacitive grounding (Ethernet connectors are a good example -- a 1nF 1kV capacitor provides sufficient rating and capacity to absorb the charge in the spark, without having to DC-ground the connection), or some combination of R, C, D and other components (often, an R||C is used to provide RF grounding and DC leakage, without inviting low frequency or DC ground loop problems; or a diode, TVS, MOV or other limiting device is used to clamp large excursions while drawing even less DC current).
I don't remember exactly what all the agencies say about it (NEC, NFPA, UL, IEC... plus myriad state and local agencies around the world!), but many of these strategies are preferred over none at all.
Further, there may be technical reasons why you can't use one of these methods. Test equipment, specifically intended for isolated use at high voltages, obviously can't use any of these (at least, nothing worse than a small capacitor and high value resistor). I don't know if there's an official way to handle that, if you need to label it as such, or what. Medical equipment cannot tolerate any leakage, so they can't use an R||C or C; instead, such equipment must tolerate the full 8kV (or more) of ESD, directly!
Tim