Ralph lost his power the moment he gave Jack the choir. By doing so he created an army that could wipe out the "civilian" population of the island (small kids, Piggy, Simon, etc.) and control the island itself. That decision was Ralph's worst decision throughout the whole book. .
On a more psychological level, Ralph is an ineffective leader because he is too young to make decisions that will be respected by the older kids. If he were an adult then maybe things would have been better, but as it stands in the book Ralph, being a kid, did not have the mental of physical capability of commanding all of these kids and enforcing his rules. Not that this means that he's a bad leader, just that he's an ineffective one at this current stage in his life. .
Now, if Ralph had not been elected leader than who would have been elected? Let us analyze the options. Firstly, the brains of the islanders, Piggy, would have been a good leader if not for his lack of physical ability and his panicky emotions, but he would not have been able to rule due to the kids not respecting him and the hate Jack feels against him. Simon seems like a good choice except that Simon is too quiet and easily embarrassed and influenced by others as is depicted on page 89 when he was trying to explain that evil is within their own minds and hearts and rebuked by Jack saying an inappropriate vulgarity in response to Simon's question. The last candidate we could consider is Jack himself. According to Piggy, the island would be a disaster zone under Jack's reign and he himself might come out being hurt by him. After considering all the options, the only possible leader is Ralph himself.
Another of Ralph's human flaws is the evil within each person's heart and the lust of savagery and meat/blood. He almost turned savage and became excited when his hunting stick got stuck into the boar in the hunt on page 113, "I hit him all right.