Fred and George are Ron's older twin brothers. They are a year above Ron at Hogwarts. They are incredible troublemakers: they spend most of Book 5 perfecting their Skiving Snackboxes, a line of candies that make you vomit, faint, or otherwise get sick to escape class. Once you've been dismissed, you can take the other half of the candy, which makes your symptoms disappear. The twins also perfect a line of wizarding fireworks that they use to create havoc inside Hogwarts once Professor Umbridge is made Headmistress in place of Professor Dumbledore.
The thing is, the twins know what they want to do with their future. They have a knack for practical jokes, and they want to set up a store to sell their Weasleys Wizarding Wheezes full time. They're only in their sixth year at Hogwarts and there are seven years in the program. Still, they have already taken their OWLs (Ordinary Wizarding Levels, the fifth year standardized exams) and they have reached the age of wizarding maturity (seventeen). What's most important, though, is that they have an investor: Harry donated the thousand Galleons he won from the Triwizard Tournament in Book 4 to Fred and George to start their joke shop. So why should they hang around for another year at school? They're only in Hogwarts in Book 5 to test their Wheezes and start marketing their products.
Since Fred and George don't really need more schooling to set up their future, they are in an ideal position to harass Professor Umbridge regardless of the consequences. Why should they care about expulsion? In fact, once Professor Umbridge bans them from the Gryffindor Quidditch team along with Harry because they attack Draco Malfoy (he talked smack about their mom!) there is literally nothing keeping them in school.
So when Harry needs a diversion to get into Professor Umbridge's office, they oblige. They set up a giant swamp to flood a whole hallway at Hogwarts. They Summon their confiscated brooms from Professor Umbridge's office using a strong Accio! charm. And they fly off from the Hogwarts grounds, after instructing Peeves the Poltergeist, "Give her hell from us, Peeves!" (29.262). After this grand example of disobedience from Fred and George (and copious leftover Skiving Snackboxes), the whole student body pretty much revolts against Professor Umbridge. She can't keep order at all, and it's in part thanks to the twins.
Fred and George provide some excellent comic relief (and rebellion) for Book 5. But their rough-and-tumble sense of humor has kind of a bad effect on Ron. They love Ron, of course, but their mockery of his terrible Quidditch performance does not help his confidence problem. After Fred and George leave Hogwarts, Ron has the best Quidditch game of his life. Hermione points out before the game, "You know [...] I think Ron might do better without Fred and George around. They never exactly gave him a lot of confidence" (30.54). Hermione turns out to be quite right, as usual.