Essentially, the quote you ask about means that if one is deprived of a stimulating existence, one creates stimulation within one's mind.
So if a person is trapped, say, in prison, or in a concentration camp, a person may live within his/her own mind, creating daydreams or fantasies. This happens often to a minor extent to many people--when they're extremely bored, for instance. But in situations of extreme deprivation, it can happen to a major extent.
I quickly reread the short story "The Shawl," so I could check out the context of the quote, but I don't see the quote in that story. It's possible I was in too much of a hurry and missed it, but I didn't see it.