Class/Spec makes a decent amount of difference once you go into content where your performance can dictate if you win or not (ie: Mythic+ with the affixes and timer, Raids with hard/soft enrage timers, adds to manage, phases to push etc). At least in terms of capable players being able to get more out of their performance. Even in situations where there are no direct output requirements, better numbers make the content easier for everyone.
That said, at the level like 98% of people play at, even if you only look at players participating in mythic+ and raiding above LFR, playing the class/spec they enjoy the most, regardless of it’s position in comparison to other classes/specs, will get the job done with plenty of room to spare. Hell, most people will outright perform better on the class they enjoy vs the class they don’t care about and only rolled because it was FotM.
It’s only really Mythic Raiding where performance requirements are so tight that this sort of thing might matter a bit, as well as very high level Mythic+ (like 15 or 20+, rewards effectively stop at 10, and any spec can do those easily).
And I don’t mean “Mythic Raiding” as in the groups that push the first ~3 bosses at the end of a tier, I mean Mythic Raiding in that the group’s goal is to full clear the raid on Mythic, and probably care about their ranking compared to other guilds on wowprogress and such.