In plain terms, Ralph is the leader at the beginning because the boys follow him, and Jack is the leader at the end because the boys follow him instead. Many interpretations and guides to the story would say that Ralph is good, and Jack is not. Ralph is good because he doesn't relinquish his efforts to remain civilized, to defend those weaker than himself, and to maintain priorities that provide the best chance of survival for the greatest number of the boys.
I think it's a little more complicated than this, at least in part, because you have to define the terms "leader" and "good," and determine if there is objective morality in this story. I think this last point would be difficult to prove because the entire point of the story is that humans become savage when stripped of their civilized veneer, and savagery could be said to be the absence of morality.
We might also say that Jack is "good" because he also does what appears to be in the best interests of those that follow him, and that his way of ruling doesn't rely on an intervention by rescuers, which from such a perspective might seem like a religion, distracting the boys from their immediate survival.
Ultimately there is fodder for arguing this in either direction, but a more specific prompt would be necessary in order to do so effectively.