"Please would you tell me," said Alice, a little timidly, for she was not quite sure whether it was good manners for her to speak first, "why your cat grins like that?"
"It's a Cheshire cat," said the Duchess, "and that's why."
Alice's Adventures in Wonderland, Chapter VI: Pig and Pepper.
The Cheshire cat is best known for its appearance in Lewis Carroll's Alice's Adventures in Wonderland, in which it has a fully formed personality, wise and knowing and cryptic and slightly obnoxious. But Lewis Carroll did not invent the name himself; in fact, the phrase was apparently in common usage over seventy years before he personified it. The first appearance in print was in the 1788 edition of the Dictionary of the Vulgar Tongue by Francis Grose: "CHESHIRE CAT. He grins like a Cheshire cat; said of any one who shows his teeth and gums in laughing." It is next found in a satirical poem by John Wolcot, writing under the pen name of Peter Pindar. At this point, 'grinning like a Cheshire cat' appears to simply mean that one is quite happy.
O, if successful, thou wilt be ador'd!
Wide as a Chesire cat our court will grin,
To find as many pearls and gems on a board
As will not leave thee room to stick a pin.
--Pair of Lyric Epistles to Lord Macartney and his ship, 1792.
Now, Cheshire is a dairy county in England, and it was well-known for its cheese. Some speculate that this is the reason that Cheshire cats were so happy, although not, admittedly because cats love cheese. Rather, the cats would hang around the cheese warehouse and wait to chase the rats and mice that lived on the cheese ships. Alternatively, maybe it was the cheese that was so happy -- some claim that Cheshire cheese originally came molded in the shape of a grinning cat. As the cheese was sliced from the tale-end first, the cat's grin was the last to disappear. Or perhaps the phrase came from the coat of arms of the Grosvenor family. One story has it that the lion on their family crest was so badly painted by the local artist that it resembled a grinning alley cat. Unfortunately, no one really tried to find out where the phrase came from until after Lewis Carroll had made it famous, so we will probably never know which story is true.
"Cheshire Puss," she began, rather timidly, as she did not at all know whether it would like the name: however, it only grinned a little wider. "Come, it's pleased so far," thought Alice, and she went on. "Would you tell me, please, which way I ought to go from here?"
"That depends a good deal on where you want to get to," said the Cat.
"I don't much care where--" said Alice.
"Then it doesn't matter which way you go," said the Cat.
"--so long as I get somewhere," Alice added as an explanation.
"Oh, you're sure to do that," said the Cat, "if you only walk long enough."
Alice's Adventures in Wonderland, Chapter VI: Pig and Pepper.
However, there are also stories suggesting that, while Carroll did not invent the phrase, or in all likelihood, know where it originated, he may have had a very specific image in mind. There are reports that he was inspired by a 16th century sandstone carving of a grinning cat on the tower of St. Wilfrid's Church in Grappenhall, a small village in Cheshire county. This town was close to Carroll's birthplace, Daresbury village. Of course, there are other stories, such as the claim that he was inspired by a carving in a church in the village of Croft-on-Tees, where his father had been rector. It is also quite possible that the Cheshire Cat was inspired by more than one piece of art, but we will never know for certain.
...she looked up, and there was the Cat again, sitting on a branch of a tree.
"Did you say pig, or fig?' said the Cat."
"I said pig," replied Alice; "and I wish you wouldn't keep appearing and vanishing so suddenly: you make one quite giddy."
"All right," said the Cat; and this time it vanished quite slowly, beginning with the end of the tail, and ending with the grin, which remained some time after the rest of it had gone.
"Well! I've often seen a cat without a grin," thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in my life!"
Alice's Adventures in Wonderland, Chapter VI: Pig and Pepper.