There have been tensions between the FIDE organization and top players like Carlsen since the latter have been promoting an alternative chess organization around Freestyle chess (aka Chesss960), which has slightly different rules.
I.e. this is less about "dress code enforcement" and it is more about "Carlsen is fed up with the FIDE organization in general".
He wasn't trying to protest the dress code or make a scene, it wasn't on his mind at all. He had been out for an appearance with a sponsor during a break, then came back to the venue for the next round, and didn't notice that he was wearing jeans and it didn't cross his mind that that would be a violation.
Then he was told to change, and there wasn't enough time for him to go do that before the upcoming round. He thought he was told he could do it either after that round or for the next day, but then was told he would be excluded from that round, and at that point he said f--- it and withdrew entirely.
The controversy was about exactly how the penalty is imposed. The rule is a fine for the first violation and disqualification for multiple. It wasn't clear if his appearance for the day would count as one violation (so he could just incur the fine and wear correct clothing tomorrow), or if each round would be a separate violation. It also wasn't clear if he could play while in violation or would be excluded from each round until he changed. Precedent from other events wasn't clear for either of these.
The headline of "disqualified" is wrong and did not happen - he chose to withdraw.
The facts are he violated the dress code rule and then withdrew when it was enforced. He then mentioned his FIDE alternative in the ensuing press coverage.
Edit: also, on paper, him attending a sponsor event and then violating a rule at the competition because he "didn't have time to change" speaks volumes about his priorities.
This is nothing more than a dumb outdated rule. He wore jeans. Not a fluorescent jump suit.