I played a wizard in Out of the Abyss which features plenty of random encounters with demons, most of which have magic resistance. Here are some of the things I was able to do:
- Buffs. Help boost the party members that are most effective at contributing to the fight. Or if you're like me and you do not trust your silly party members you can always Polymorph yourself into a t-rex so that you can now contribute. Sure it's attacks aren't magical so you'll be dealing half damage, but half of a lot of damage turns out to be pretty okay damage. Also having the constitution of a dinosaur will help you on those concentration saves.
- Control without saves. They're few and far between but there are spells that don't require a saving throw that do a bang up job controlling the field. Wall of Force is the cream of the crop here.
- Play the numbers game. If you hit enough targets with a spell like Hypnotic Pattern it's likely that at least one of them is going to get a bad roll. So if the enemy is grouped up it might still be worth it to try to lock some things down.
- Just blast em. The best condition is dead, so sometimes you just need to help your martial comrades in the damage race. Try to pick up some blast spells that make spell attacks to target AC like Scorching Ray. A lot of creatures with magic resist will typically also resist energy attacks so if you know these types of creatures will be a threat picking up Magic Missile might not be a bad idea. I wrote off Magic Missile completely, but I came to appreciate how it is almost never a dead spell.