Lewis Carroll's Alice’s Adventures in Wonderland, despite its linguistic and literary sophistication, is a book written for children with the narrative viewpoint of a young child. Alice was modeled on the daughter of the distinguished Oxford classicist Henry Liddell. Although Alice's voice is that of a very logical and intelligent child, she is still a child, to whom much of the adult world appears mysterious and inexplicable. Thus the use of nonsense in part serves to give us a sense of how the adult world often appears nonsensical or incomprehensible to children.
A second use of nonsense is as an illustration of Carroll's theory of language. As a mathematician, he had a generally formalist understanding of how language worked, i.e. that it functions as an inherently arbitrary symbolic system of rules, much like the rules of Wonderland croquet or of the mad Hatter's tea party. As many of the rules of ordinary games or etiquette in our world have an arbitrary nature, the exaggerations of their portrayal in the novel make us look critically at the rule systems of the real world and make us aware of their inherently irrational nature. Alice’s Adventures in Wonderland itself, though, is not a philosophical treatise, and despite the intellectual interest of these passages, their main point is sheer entertainment. The croquet with flamingos and hedgehogs is delightfully funny to readers of all ages.
Nonsense also functions to evoke the fantastic dreamlike nature of the world.