The first half of House's season 4 was focused entirely on House running a doctor tournament to get a new team, and included some of the best episodes and best characters of the show's run; Thirteen, Kutner, Taub, Amber as well as the other minor doctors
Friday Night Lights integrated almost a completely new cast for seasons 4 and 5 very well, and is one of the very few “high school” shows to execute the transition from HS to college well for their main cast members. Not only that, but they took Coach and put him into a completely new school after we had spent 3 years rooting for the Dillon Panthers AND then made the Panthers the bad guys - completely flipped our allegiance. But by the end of it, I loved the East Dillon Lions almost as I had loved the Panthers.
New Girl swapping Coach for Winston after the first episode. They even brought back Coach at one point.
Cheers did it well with Coach and Woody. Diane and Rebecca. I'd say MASH is the gold standard though.
MASH swapped out a few different people and was still great.
Charmed seemed to do pretty well post-Shannen Doherty. Other than that, I really can't think of many instances. Even the examples you listed, most fans agree the shows were still fine, but not as good.
Doctor Who, nobody does it better
For whatever reason the first thing that came to mind was Big Bad Beetle Borgs lol. An absurd childrens show where one of the main child actors changed and was explained throught magic. We saw the new acrtress but to everone else (all the characters) she looked like the old actress.
NCIS when Sasha Alexander left the series and Cote de Pablo joined it. The show only became more popular in subsequent seasons.
IT Crowd when Denholm Reynholm (Chris Morris) is replaced by his son Douglas Reynholm (Matt Berry).
[His introduction at his father's funeral](https://www.youtube.com/watch?v=tcnVA1xqRU4)
BONUS: [Denholm's death](https://www.youtube.com/watch?v=ejfYttZCnps)
Parks and Rec. Mark Brendanaquitz was originally the leading man and they phased him out seamlessly for the major additions of Adam Scott/Rob Lowe.
Also, not sure if It's Always Sunny counts since it was just adding a cast member without losing anyone, but Frank's introduction in S02 was outstanding.
Also, I have to disagree with what you said in your OP. The Office was fucking awful after Steve Carrell left. They left on a high note with having an outstanding series finale, but the show was really bad for about 2 years. I straight up hate watched it but was rewarded by a really strong finale.
I'm not sure it's the absolute best example of seamless major cast change, but Community certainly [addressed](https://www.youtube.com/watch?v=ZUiJCNf44WQ) it better than any other show.
Monk pulled off two big changes, and did so seamlessly.
I really thought Monk wouldn't be as good after Bitty Schram left, and I wasn't a huge fan of Traylor Howard prior to seeing her on Monk, but she turned out to be a great replacement and the show had some of its best episodes after Sharona left.
Then later Stanley Kamel, who played Monk's beloved psychiatrist, died suddenly of a heart attack. They wrote his character's death into the show and brought in a new psychiatrist played by Hector Elizondo; Elizando does a wonderful job, and the writers do a good job of addressing Monk's grief.
They did an amazing job of getting you invested with the new characters. I thought their finale where they wrapped all of the current story lines, while throwing back to all of the "classic characters" as well.plus the merging of old and new with Rachel Greene coming back to County to continue her fathers work
Married with Children replacing Steve with Jefferson. That was probably the only time that Ted McGinley joined a show and it actually got better instead of worse.
After Richard Dean Anderson finally left, they brought in the two leads from Farscape to join the team and the show continued on it's merry way being consistently good. It could have easily gone on for many more years with the season 9/10 team members. Some people didn't like the new villains and plot, but to me the show held it's quality in entertainment week after week.
Stargate Atlantis replaced a core team member that was bland in season 1 with Jason Momoa and that really improved the show.
Legends of Tomorrow
Season 1 started with 11 main/major recurring (9 heroes, 1 AI, and 1 villain) but ended with 7 main (6 heroes and 1 AI)
Season 2 started with 11 main/major recurring (8 heroes, 1 AI and 2 villains) but ended with 8 main/recurring (7 heroes, 1 AI) but 2 other villains reoccurred during the season
Season 3 began with 8 main/recurring (7 heroes, 1 AI) and ended with a giant teddy bear brawling with Satan (10 heroes, 1 AI, 2ish villains) but a handful of heroes/villains dropped in and out of the season.
Of the original cast, only 5 have stuck around, with many more having joined this past season.
DS9 adding Worf was a huge thing. You have this already iconic character being added to a working cast around half way through the series' run. So it could either be a total mess or work out in an amazing way. It managed to fall into the latter, and we really saw more depth to the Klingon side of things and Worf as a character. The addition of Worf didn't upset the balance and actually DS9 became a better show from then on.