They are bonded to ground so that if a hot happens to run or chaff up against them, you don't have hot water or gas lines conducting in your house -- a dead short to ground will trigger a breaker overload (near) immediately assuming they are working correctly.
If these pipes were not grounded, they are just pretty scary conductive pieces of metal strewn throughout walls and ceilings, and usually terminating at a place where people physically contact, as well.
If these pipes were not grounded, they are just pretty scary conductive pieces of metal strewn throughout walls and ceilings, and usually terminating at a place where people physically contact, as well.