By federal law any government or private company which provides water to at least 25 people on a regular basis must comply with certain testing requirements. Assuming that the required level of testing occurs, that means the water at it's point of distribution is of reasonable quality. However, there are a number of things that can happen between that distribution point and your faucet tap. In many cities and towns the water pipes could be several decades old, in some communities the pipes could be over a century old.
Ground water can enter cracked or broken pipes bringing any number of contaminants with it.
In some cases there are faulty flow control valves which can allow other customer's water to back flow into your water supply. Chlorine is often added to public water. Trihalomethanes are a group of chemicals that are created as a by product of chlrorinazation. These chemicals are suspected carcinogens if their levels exceed certain limits. Any home constructed prior to 1990 may have plumbing pipes that were joined together using lead based solder.