It matters because it gives an indication of whether the dress code is necessary for some reasonable reason (e.g. they want their employees to look nice) or because they were just suppressing unionisation.
The reason for doing something almost always has implications on the legality of you doing that thing. Since we don't have mindreading devices or truthtelling serum, judges use patterns and heuristics to make their best guess as to the reasons for actions.