Fred and George came back into the room carrying Harry’s school trunk. They glanced around as they entered and spotted Dudley. Their faces cracked into identical evil grins.
The purpose of this chapter within the context of the larger story is mostly to get a laugh early. Sure, Fred and George conjuring magical tricks and candies is going to be a larger part of the plot of multiple books, but this chapter is about torturing the Dursleys and allowing the Weasley family to earn the reader's love. This is the sort of plot diversion that really only works smack dab in the middle of a series rather than the beginning of a standalone book.
I would argue that though decidedly unpleasant, Dudley hasn't done much to Harry in this book to deserve his comeuppance. He's done plenty in previous novels, of course, and the return reader will be happy to see Dudley magically tortured once again. But he's mostly paying for previous crimes. More important, the reader will appreciate representatives from the Weasley family first standing up for Harry:
“Well . . .’bye then,” Harry said to the Dursleys.
They didn't say anything at all. Harry moved toward the fire, but just as he reached the edge of the hearth, Mr. Weasley put out a hand and held him back. He was looking at the Dursleys in amazement.
“Harry said good-bye to you,” he said. “Didn’t you hear him?”
“It doesn’t matter,” Harry muttered to Mr. Weasley. “Honestly, I don’t care.”
Mr. Weasley did not remove his hand from Harry’s shoulder.
“You aren’t going to see your nephew till next summer,” he said to Uncle Vernon in mild indignation. “Surely you’re going to say good-bye?”
And then torturing the Dursleys:
“See you,” said Harry, putting one foot forward into the green flames, which felt pleasantly like warm breath. At that moment, however, a horrible gagging sound erupted behind him, and Aunt Petunia started to scream.
Harry wheeled around. Dudley was no longer standing behind his parents. He was kneeling beside the coffee table, and he was gagging and sputtering on a foot-long, purple, slimy thing that was protruding from his mouth. One bewildered second later, Harry realized that the foot-long thing was Dudley’s tongue — and that a brightly colored toffee wrapper lay on the floor before him.
Just as we saw Harry stand up to Uncle Vernon last week, establishing his character, this scene establishes the character of the Weasleys. And more, it's just fun. Readers everywhere enjoy seeing Dudley tortured. It's a small celebration, like a fountain of sparks before Rowling busts out the Gandalf-style fireworks she has in store for us later in the tale.
The Dursleys rounded on Harry like a pair of angry wolverines.
His last fleeting glimpse of the living room was of Mr. Weasley blasting a third ornament out of Uncle Vernon’s hand with his wand, Aunt Petunia screaming and lying on top of Dudley, and Dudley’s tongue lolling around like a great slimy python. But next moment Harry had begun to spin very fast, and the Dursleys’ living room was whipped out of sight in a rush of emerald-green flames.