Peter Peter pumpkin eater,
Had a wife but couldn't keep her.
He put her in a pumpkin shell,
And there he kept her very well.
Peter, Peter pumpkin eater,
Had another and didn't love her;
Peter learned to read and spell,
And then he loved her very well.
The initial verse can also be taken in the sagacity that, by placing her (alone) in the pumpkin, he rid himself of a wandering wife. Note, however, that he doesn't stay in the pumpkin. Rather, she is put there and her assignment has eased Peter's responsibilities regarding her well-being. After all, many nursery rhymes have some pretty dark themes; such as "Ring Around the Rosey," which is purported to be about the Plague. On the other hand, it could be thought of a man taking care of his wife by housing her someplace edible.
The subsequent verse, however, tells of how he moved on to another wife, so to speak. This takes away most "caring" personality that may have been credited to Peter earlier and suggest that Peter wasn't able to keep his tasks to his wife and got rid of her. (Much like the suggestion of murder). Though the difficulty of the second verse is love and not Peter's ability to "keep" his wife.
Another explanation of the first verse suggests maybe Peter was not able to keep up with the sexual appetite of his wife. Thus, his accountability for keeping her was pleasing her sexually. It is a play on words: if a pumpkin-eater were to put his wife in the shell of a pumpkin, it suggests that he would then eat her, "eat" being a euphemism for oral sex performed on a woman. The shell of the pumpkin is imagery that supports this view, as well as the imagery of eating.
The next verse perhaps suggests that Peter's first wife left him, or he kicked her out. It is reasonable that he could not intellectually keep up with his second wife and therefore she was not aroused by her husband. So Peter, rather than try to change his wife as in the first time, tried to change himself. He was able to then keep her because he made an effort, rather than just forcing his wife into something she was not.