Electroshock therapy is effective about 50% of the time. It works by inducing a seizure to treat depression. Those who respond to the therapy typically relapse within twelve months, so electroshock therapy isn't a long-term solution (if you can call it a solution at all). Electroshock therapy is still used today although it is rarely the first treatment for depression or bipolar disorder. It requires informed consent, which means that if a patient refuses the treatment, it cannot be forced onto them.
The health risks of electroshock therapy are equivalent to that of general anesthesia. When I was reading the book, I assumed that electroshock therapy was doing the opposite of what it was supposed to, but that isn't necessarily true. It's safe to have the treatment when you're pregnant!
It is true that electroshock therapy may have been detrimental for Esther. It is also true that electroshock therapy could have been quite helpful for Esther. No matter what the exact cause of Esther's renewed well-being is, she ends the novel ready to leave the asylum and away from electroshock therapy.