Great question. To answer it, I'd take you back to the moment at which Piggy reveals his "name":
“I don’t care what they call me,” he said confidentially, “so long as they don’t call me what they used to call me at school.”...
“They used to call me Piggy.”
Ralph shrieked with laughter. He jumped up. “Piggy! Piggy!” “Ralph—please!” Piggy clasped his hands in apprehension. “I said I didn’t want—” “Piggy! Piggy!”
Golding is actually quite merciless to Piggy - we never find out his real name. And young boys are cruel, and Ralph cannot help but find it hilarious. He hasn't yet grown up enough to understand that it will hurt Piggy's feelings.
Here's the moment Ralph gives the game away:
“Shut up, Fatty.” [said Jack Merridew]
“He’s not Fatty,” cried Ralph, “his real name’s Piggy!”
“Piggy!” “Piggy!” “Oh, Piggy!”
A storm of laughter arose and even the tiniest child joined in. For the moment the boys were a closed circuit of sympathy with Piggy outside: he went very pink, bowed his head and cleaned his glasses again.
Ralph is keen to gain favour with the other boys: and one way to do that is to collectively mock someone else. And this is what happened: a "closed circuit of sympathy", with Piggy outside. Ralph doesn't mean any malice - but he can't help himself but share the hilarious joke. Only Piggy, at this stage in the novel, is mature enough to know better.