The moment that best enlightens us about the role of the snake is the moment that the Little Prince first meets the snake. The Little Prince has just arrived in the desert and is very surprised to see how empty it is of humanity. He ponders returning to his own planet. The snake, just like the snake in the Garden of Eden, symbolizes death and philosophizes with the prince about the nature of mankind and even the nature of life and death itself.
We know that the snake symbolizes death because it is a very poisonous snake that can kill within moments. The snake is well aware of its capabilities, as we see when it refers to itself as being "more powerful than the finger of a king." The snake also likens its ability to kill with the ability to "send back to the earth from whence [a person] came." This reference to earth can be interpreted as a reference to a person's origin, rather than a planetary reference, just as Adam was created from the dust and mankind returns to dust in death. Hence, we clearly see that the snake symbolizes death.
However, another interesting point about the snake is that it philosophizes about mankind, mankind's life, as well as death. We especially see the snake philosophizing about mankind when the prince points out that it is lonely in the desert and the snake replies, "It is lonely among men." The snake's point is that mankind is full of so many flaws that mankind creates distance and loneliness among themselves, creating a very lonely life for themselves. The snake also philosophizes about the nature of both life and death when in answer to the prince's question, "But why do you always speak in riddles?," it replies, "I solve them all." What the snake is referring to is that death is considered to be the most puzzling experience, the greatest riddle of life, and by sending people to their death, the snake is helping them "solve" the greatest riddle.
Hence, we see that the purpose of the snake is to symbolize death and also to philosophize about death and human nature.