People use bleach for two reasons:
How does bleach whiten things? This page has a simple explanation:
Natural stains are produced by food, grass and mildew, to name a few. The stains come from chemical compounds called chromophores. When the chlorine reacts with the water in the washing machine, it produces hydrochloric acid and oxygen. The oxygen reacts with the chromophores and eliminates the part of the molecular structure that caused the colored stain.
This page provides a little more detail:
They are oxidizing agents,
that is they remove electrons from the substance that causes the stain. In
many cases, but not all, the oxidized form of the stain is colorless, or at
least less highly colored than the reduced form, so the stain disappears... So the general mechanism of a bleach is a chemical reaction in which the reactants are colored but the products are not.
How does bleach kill bacteria?
The researchers found that hypochlorous acid, the active ingredient in bleach, causes the unfolding of proteins in bacteria in much the same was that heat stress or fever does. Those denatured proteins then clump together irreversibly into a mass in living cells, similar to what happens to proteins when you boil an egg, according to the researchers.
If you put bleach in water, it will kill bacteria and tend to lessen anything that might be coloring the water. That's why chlorinated water is so common in municipal water systems and swimming pools. Tap water might have a chlorine concentration of 1 part per million (anywhere from 0.2 ppm to 4 ppm is legal) (see this page for some specifics of what gets into tap water). A swimming pool can go as high as 4 parts per million for swimming, and can go much higher for shock treatments (as discussed here).
People use chlorine bleach as a disinfectant because it is fast, inexpensive and relatively benign to the environment. If you treat water with chlorine and then let it sit, the chlorine will be gone 24 hours later.
However, strong chlorine bleach (like you find in a bottle of bleach, which is 5% to 6% sodium hypochlorite mixed with water) is not something to treat lightly. You do not want it getting on your skin, in your eyes or into your lungs. If you dilute one ounce of bleach with 8 ounces of water you have a solution that kills germs but is not nearly so dangerous to your eyes and skin. Work with bleach in a well ventilated area. If you are using it in a bathroom, turn on the fan or open a window. If you get chlorine bleach on your skin, wash it off immediately using plenty of water. If you do not, you can get chemical burns as described here:
Chlorine bleach is sodium hypochlorite, whose dangers are well known. The Agency for Toxic Substances and Disease Registry says, "If concentrated hypochlorite solutions contact the skin, chemical burns may occur; treat as thermal burns. Patients developing dermal hypersensitivity reactions may require treatment with systemic or topical corticosteroids or antihistamines." An MSDS (materials safety data sheet) page on sodium hypochlorite indicates "IRRITANT, MAY CAUSE BURNS AND/OR RASH ON SKIN AND MUCOUS MEMBRANES."
Use gloves to keep bleach off your hands. Use goggles to keep bleach out of your eyes. Be very careful when pouring bleach out of a bottle.
Bleach is not something you want to be mixing with other chemicals, as described here: Common cleaning products can be dangerous when mixed
Chlorine can be made from salt using electrolysis. Salt is NaCl - sodium and chlorine. Electricity will break the two apart and release the chlorine, as seen here:
The use of chlorine in war and the laboratory: