If there is anyone who still needs a spoiler-warning, yes, this post contains spoilers on The Rise of Skywalker.
"Serpent! Serpent! Serpent!" C-3PO cries out, and a percentage of the audience shouts out, Alice in Wonderland! Star Wars being archetypal and all about symbols and themes, it would follow that they would directly include literary references (especially given that one of the writers, Chris Terrio, was a lit. major). But why include this particular reference?
The snake scene is full of symbolic value. It is one of the many examples of healing from past harm. D-O runs from Rey's touch and then, once he is able to trust again, helps the Resistance. The snake first appears threatening, as if ready to kill the company, and then ends up helping them find a way out after Rey shows it kindness in healing its wound. Kylo experiences kindness and acceptance and forgiveness from Rey where before he only felt hurt and unworthiness--and so he chooses to lay aside the past. In the simplest form, the snake is Kylo. Rey literally heals both of their physical wounds and then receives assistance from them both.
The snake is also a traditional symbol of evil and temptation and disobedience and rebellion, going back to the garden of Eden. And the redemption story that you see in the film in D-O, the snake, and in Kylo Ren/Ben Solo is essentially a recovery of the Fall from Eden. The snake was a symbol of evil and that's why 3PO and Finn and Poe were afraid of it, ready to just kill it to protect themselves. But Rey didn't want to stop at saving her life; her aims were higher. She was on a mission. So instead of killing instead of being killed, she won the snake over to her side and consequently was speeded on her way. She took what had been given the name of evil and gave it a new name.
Just as she gives herself a new name. And that's where the Alice in Wonderland reference comes in. That story is all about "nonsense" situations that in some way express the concept of growing up. The serpent quote comes from when Alice is growing so much that her neck becomes very long and reaches into the sky so that she can't even see her hands. So she starts craning her neck into the trees to look for the rest of her body, and a bird shouts serpent at her and explains that she has been trying to keep her eggs safe from serpents. Alice tries to explain that she's a girl not a serpent and that even though she does eat eggs, she doesn't eat eggs like that; but trying to explain her actual identity is difficult in the circumstances and the bird really doesn't believe her.
It really isn't nonsense if you look at it on a symbolic level. The core of it is establishing personal identity--even in the face about assumptions from other people about that identity, assumptions that can even start to get you questioning who you are. Alice tries to say that she doesn't want the bird's eggs because she's a girl not a serpent--but she also has to admit that girls eat eggs, too, even if it isn't like that. Rey is trying to affirm that she is not a dark Jedi or the heir to the Sith--even when she does things (like using the force to heal physical wounds, perhaps?) that are traditionally associated with the dark side. She even doubts herself, fearing the vision she has of herself on the Sith throne with Kylo.
But Rey is more aware of what is going on than Alice is. Rey is a woman choosing her path in life, not a girl coming of age. She realizes that no one can make her be something that she doesn't choose. She is heir to Palpatine but she does not have to accept the inheritance of darkness. Instead, she chooses to be adopted into the Skywalker lineage, into the legacy of hope and light. Rey, in choosing her identity, initiates healing and redemption from the Fall.