The location of the anal sac makes even a benign growth a problem because it impinges on the surrounding structures. Diseased sacs may be very painful and may require some level of pain relief medication and perhaps a tranquilizer or sedative to keep the treatment from being a bad experience for the pet. In addition, your veterinarian may use a lavage to wash out the anal sacs. For some dogs and even some cats, anal sac disease becomes a severe, repeated, and persistent experience. It is recommended that both sacs be removed at the time of the surgery.
Anal sacs have no known beneficial purpose for dogs and cats.
I often compare the anal sacs to the appendix in humans. As long as it is healthy, we leave it alone even though we don't need it. For more information, contact your local veterinarian.