Knowing what you are potentially up against is already built into the system. Maybe a more robust inspiration/metagame mechanic that can allow a character to overcome a resistance or immunity on this one particular Attack?A player in my game the other night hit one time in 3 hours of play, and not for lack of combat challenges. I don't think he succeeded on any ability checks either. Even though the game itself was fun and produced a memorable story, part of that story was that character wasn't very effective. No doubt it would have been more fun to have contributed more to the group's progress.
I think this is somewhat on par with being stunned or paralyzed - you're just not contributing much compared to other characters in that moment. Damage or condition immunities (a category in which legendary resistance kind of falls) are also not fun to find out about after wasting a spell or other resources on it. You might as well have been stunned or paralyzed that turn for as much as it contributed (outside of establishing the immunity as fact), plus you conserve the resource!
As far as solutions to the above, I think moving combat along quickly to get more turns in the smallest amount of time helps (in hopes things turn around), as does "progress combined with a setback" on a failed ability check so that things move forward. Damage and condition immunities can be telegraphed up front so that the players know something like legendary resistance is a thing they will face, and they can then strategize on how to get around it.
I actually prefer the old 3.x system for this reason. DR could be overcome with bigger damage, and there are tools for getting bigger damage. There aren't many tools for just suddenly making your sword damage necrotic.