To me, the game plays fine as long as all of the players are roughly around the same power level. I mean power-level twofold, both able to contibute in their way in combat (the most mechanically-lengthy common part of the game) and equally able to gain spotlight out of combat. I'll say this is roughly comparable to "how optimized are your characters" to answer your question. (And a note that party optimization is actually one of the most powerful force multipliers specifically in D&D 5e game), more than individual optimization.)
So as long as everyone "optimizes" the same amount, and of course the DM actually adjusts, optimization has absolutely no effect on game play. Everyone equally incredibly min/maxed or "hopeless", and a DM makign challenges to a suitable level, and we're all good. A DM thjat doesn't adjust, including pre-written adventures, is failing at an important part of their job.
The problem occurs when a minority of players are much weaker or stronger than the rest of the party. The DM can tune thigns to deal with both sides simultaniously but not perfectly on an every-time basis. In reality, things are often catering to one side or the other, and the other side gets boredom (either from not being able to contribute or by not having any challenge).
Though even that has a caveat that if the single/minority are "more optimizing" are playing characters to make the other PCs shine like support characters, healers, defenders, then they know what they did but others don't feel slighted and it works well. Note that it doesn't work the other way, so in that corner case more optimization beats less optimization for making everyone have fun, while in other cases it has little effect on game play unless uneven.