The idea of killing Ralph is the culmination of a transformation that begins when Ralph is elected chief instead of Jack. Jack felt he should have been elected chief because he was head of the choir. His feelings are hurt and those hurt feelings turn into bitterness and revenge as "the beast" or the evil in Jack is allowed to grow because of poor leadership on Ralph's part and basic human nature.
Golding's entire theme points to the idea that there is "a beast" inside of every person that must be controlled by a strong government and strong laws. The island environment has neither. There are no adults or stronger boys to enforce the laws and Ralph tries to placate Jack by giving him leadership of the hunters. Once he learns to kill a pig, killing a human is not that much of a leap if no one is there to stop you.
So, with one to really control Jack, his behavior becomes more and more evil until he is ready to do what would have been unthinkable at the beginning of the novel. Ralph is the last threat to Jack's power over all of the boys and once he sees that power becoming possible, stalking and killing Ralph becomes much like stalking and killing a pig.