Celtavian is right in that, when it comes to Legendary monsters, most casters are at a very large disadvantage.
At the furthest extreme, take Tiamat. She's flat out immune to every spell below level 7. For the 20th level warlock, that means only three spells they could use, and heaven help them if any of them are Save or Die effects, or a utility spell, and even the blade lock will be doing sub-optimal levels of damage thanks to the lack of Hex. All other full casters get four spells, which are more flexible, but still come down to primarily Power Words or Polymorphing. Why? Because even those high level spells have to beat her insane saves with advantage on them. Rangers, likewise, are behind the curve in terms of damage - they get lots of bonuses against hoards, but single targets rely on Hunter's Mark for an increase of damage, which Tiamat is immune to. A level 20 ranger barely deals more damage than they did at level 5 against Tiamat.
That leaves paladins (relying only on their regular smites, not spell-smites), fighters, barbarians, monks, and rogues to do any significant damage. A valor bard who steals a spell smite via magical secrets could get in on some of the fun too, I suppose, if you cast them as the level 7, 8, and 9 spell slots.
Now, lets look at the Tarrasque. No magical attack rolls - this again makes the warlock cry, because that means no cantrip damage, and the sheer majority of their spells are either Save or Die, necrotic, or fire (which the Tarrasque is immune to). The tarrasque also reflects line spells like lightning bolt, as well as magic missile. Those are some of the most spells and effects he's flat out immune to. He has magic resistance as well as high saves in everything but Dex, so we're talking ~ +9 with advantage to resist most spells. Being immune to both fire and bludgeoning, the Tarrasque is actually flat out immune to Meteor Swarm damage.
That Tarrasque is not immune to Disintegrate and has weak Dex saves, so that ends up being a good attack spell to focus on. Though, we have to contend with Legendary Resistance at this point - he pops a Leg.Resist, and no damage from the spell.
Where does that leave us with magically harming the Tarrasque? Circle / Finger of Death are Con saves, he'll likely make them. Cold spells have nothing beyond Cone of Cold and Otiluke’s Freezing Sphere (a wizard only spell) and again, Con save for both. Negligible damage. We can try powering through his Legendary Resistance, but again, most spells he shrugs off by virtue of high saves and magic resistance, no need to use them. Disintegrate is the exception, but that requires three turns at minimum before it actually has any chance of harming him, and actually being in a class that has the spell. Power Words are effective, but you need to get him down to an acceptable amount of HP first. And then, there's the Polymorphs.... which just turn you into a melee warrior.
Now, these are two of the most extreme examples here. That's a given, with their CR 30 rating. But it just highlights the point the OP is trying to make - Legendaries tend to shrug off ALL magic, not just the Save or Die effects. It would be bad if the Big Bad Evil Girl fell to a Dominate Monster spell in the first round, yes. But as a side effect of making them resilient to all this stuff, casters suddenly aren't very effective at all against them. Your blasters are relegated to buffing the martial characters.
This is where we run into issues. The big, dramatic boss battles are suddenly not very interesting for half the classes. This is not a revelation, but something a lot of people have mentioned before elsewhere.
Truthfully, though, this is an issue with the rules on the bosses, not the casters. Single boss, epic battles have always been an issue in turn based games. My best suggestion, at this point, is to either be generous with evocation damage when it comes to Legendaries, or don't make them solo encounters, but include things like minions appearing. Boosting caster damage, especially with some of the magic items that seem to be coming out? I don't think that's the answer.