The primary theme of "The Yellow Wallpaper" is that women who are suffering from post-partum depression, or any kind of depression, should be respected and allowed to make decisions regarding their own lifestyle and health. The rapid decline that Jane experiences under her husband's care and watchfulness and "the rest cure" could have been prevented if John had listened to Jane's desires. Jane wants to write, which would have certainly been a healthy pursuit for her if she had been allowed to do it openly. If others had taken an interest in her writing, that would have boosted her self-esteem. Perhaps she could have written about the sadness she felt, and getting it down on paper in a way that she could share with others might have been a tonic for her. Only being able to write on the sly turns her legitimate desire to express herself inward, exacerbating her dark thoughts.
Jane also expresses the desire to go visiting, but her husband squashes the idea, assuming it would be too hard on her. Seeing friends could have done wonders for her psychological state, but John is perhaps too embarrassed that his wife is suffering from a "nervous" condition to allow her to appear in public and possibly damage his reputation as a physician.
Jane's original complaints about her environment should have been heeded, as well. She did not seem to be in favor of the move to the country house, and she detested the wallpaper. Surely a small investment in making the room cheerful and attractive was not too much to ask, yet her requests for changes in living arrangements were consistently ignored.
John generally treats Jane with a lack of respect. When she tries to express herself, he often laughs at her or cuts her off. He manages to do this in a way that seems kind, making his control over her all the more egregious because she feels ungrateful for balking at his rules. Having a husband and doctor who respected her as a complete person, not as some childish half-wit, could have spared her the plunge into insanity that she experiences at the end of the story.
Often authors leave it to readers to determine the themes of their stories. In the case of this story, however, we are blessed with a specific explanation from Charlotte Perkins Gilman of her purpose in writing the story. You can see her explanation at the link below. Ms. Gilman suffered from "melancholia" herself and was prescribed the rest cure; she knew first-hand how destructive it was. She wrote the story as a way to encourage doctors to stop prescribing it and to bring attention to its dangers. She was able to return to a normal state of mind because a "wise friend" respected her and helped her pursue her own instincts about what she needed to do. Gilman left a powerful illustration of how important it is for women to be respected.