The surgery is most commonly done for diabetic dogs who have developed cataracts.
The lens is covered in a thin membrane, and a small circle is cut out of this membrane. If this goes well (ie, you didn't wait to long to do surgery so the membrane is weak), then an artificial lens can be put in place. To remove the catact, the lens is broken apart by a special machine in a process called phaecoemulsification. This process can sometimes cause the dogs heartrate to drop dramatically, but having seen it personally, it can be managed with careful monitoring.
The cornea is then sutured closed again, and will sometimes scar. There can be a lot of inflammation in the eye short-term after surgery, especially if there are any parts of the cataract left in the eye. Once the inflammation is controlled, then vision is restored.
If you do not do the surgery, the risk of cataracts is that the thin membrane will eventually rupture, usually leading to so much inflammation that glaucoma results. Glaucoma is an end-stage process at this point, and either chemical destruction or surgical removal of the eye is recommended at that time.
Surgery runs, on average, 2500-3500 per eye, and is only performed by surgical specialists (most often ophthalmologists).