Simon's purpose was to show the others that the boys are innately evil, and that the beast is within themselves. This is because William Golding had no better way to present the idea of the boys themselves being the beast; introducing it indirectly was more effective than narrating it.
Golding uses Simon's conversation with "the beast" or the sow's head on a stake to explain fully the idea of the evil within the boys actually being the beast. Simon has been set up as the only boy that really understands what is happening and his vision is the one that finally brings home to him where the beast comes from. Golding also uses it to foreshadow Simon's beating and death at the hands of the boys which links permanently the idea of the beast with the behavior of the boys and their willingness to even purposely kill one another to try and fight off their fear of the beast or their fear of their own inner nature.
Epilepsy was once thought of as a curse or as a condition that gave one prophetic power. Simon's disease separates him from the other boys and helps him represent the spiritual side of goodness and kindness. He stands in stark contrast to Jack, who symbolizes the evil side of mankind. Simon's violent death, which occurs when he tries to bring the truth about "the beast" to the rest the boys, adds to both the Biblical motifs of the story and the idea that mankind often rejects the truth about its own evil nature. "The beast" is, after