Right at the start of the novel, when the other boys start to appear, Piggy recognises that he might have an ally in Ralph: as the choir, led by Jack, appear:
Piggy asked no names. He was intimidated by this uniformed superiority and the offhand authority in Merridew’s voice. He shrank to the other side of Ralph and busied himself with his glasses.
Then, shortly later, Piggy again is seen to be given confidence by Ralph's presence, until Jack shoots him down:
Secure on the other side of Ralph, Piggy spoke timidly.
“That’s why Ralph made a meeting. So as we can decide what to do.
We’ve heard names. That’s Johnny. Those two—they’re twins, Sam ’n Eric. Which is Eric—? You? No—you’re Sam—”
“ ’n I’m Eric.”
“We’d better all have names,” said Ralph, “so I’m Ralph.”
“We got most names,” said Piggy. “Got ’em just now.”
“Kids’ names,” said Merridew. “Why should I be Jack? I’m Merridew.”
Ralph turned to him quickly. This was the voice of one who knew his own mind.
“Then,” went on Piggy, “that boy—I forget—”
“You’re talking too much,” said Jack Merridew. “Shut up, Fatty.”
Piggy is given confidence by Ralph as a leader, and by the schemes that Ralph sets in place. So shortly after Ralph announces the way the conch will be used at the assembly, Piggy is straight there using it:
Ralph felt the conch lifted from his lap. Then Piggy was standing cradling the great cream shell and the shouting died down. Jack, left on his feet, looked uncertainly at Ralph who smiled and patted the log. Jack sat down. Piggy took off his glasses and blinked at the assembly
while he wiped them on his shirt.
“You’re hindering Ralph. You’re not letting him get to the most important thing.”
He paused effectively.
“Who knows we’re here? Eh?”
Piggy knows that Ralph's values are the same as his own. And, even though Ralph sometimes turns against him, he relies on Ralph - and the sort of reinforcement he makes of his leadership in the above quote - and Ralph's status - to have his own voice.