Charlotte Perkins Gilman's "The Yellow Wallpaper" was first published in 1892. The narrator is described as having what was in that period called a "nervous disorder" or "mental breakdown" for which her doctor has prescribed rest as a cure.
The first thing we discover about the narrator is that she is taking some sort of medication for her mental illness. She states:
So I take phosphates or phosphites—whichever it is, and tonics, and journeys, and air, and exercise, and am absolutely forbidden to "work" until I am well again.
We don't know precisely what sort of medications she is taking, but they might well have the side effect of making her sleep more.
Next, we have the issue of her own mental state. Although we get mainly an internal view of how the character feels, we do know from the opening of the story that she was suffering from some form of mental illness. Especially if the narrator is suffering from depression, one of the typical symptoms is excess sleeping.
Finally, as she is locked in an empty room, she really has absolutely nothing she can do other than sleep.