This is actually a good illustration of the fact that people making decisions for a corporation rarely put the shareholder's interests first.
If you're hiring and the interviewee looks like they are homeless, but for whatever reason they demonstrate that they are the most competent candidate for the job, then your choice is to either toss them for their appearance and hire a less competent candidate, or hire them. Now, if they absolutely reek of body odor perhaps you'll have to have them work from home or sequester them into an office with self-contained ventillation or else half the rest of the department will quit. All of those concerns are legitimate business concerns if your sole preoccupation is with making your shareholders as much money as possible.
However, a lot of other factors weigh into the decision like what people will think of you as a manager if you hire a "bum" and those tend to take priority over making your shareholders money.
This is just one example, and dress code isn't a particularly strong one. Managers don't make decisions to make companies money - they are motivated primarily by self-interest, and to some extent corporate policies help to align that self-interest with making the company money.
This is part of why start-ups tend to put little emphasis on things like dress code, tend to be much less rigid, etc. The owner knows everybody, and for a company where the decisions are made by the owner, self-interest and making money for the shareholders are almost perfectly aligned. Even if there is a layer of management or two involved, the shareholders aren't some disconnected and abstract force - they're people just down the hall who check in frequently and know everybody's name.
I once had to buy dry ice and bought it from a small business which clearly wasn't retail-oriented. I walked into the office door and asked if they would sell to private individuals. They responded that as long as the money was green that they would take it. I work for a company that employes 50k people. If somebody walked up to the security gate and offered $10M cash for 1 pound of dry ice (which could be obtained from a building 100 yards away easily) nobody would give them the time of day or have any idea how to make that work even if they were inclined to do so. Most likely they would be turned away, or if they had a desperate need they might just be given it free of charge. The idea of actually selling something for outrageous profit is so abstracted away there just isn't any process for doing it. The company certainly sells product, but completing a single sale probably involves 100 people doing 1/100th of the task each across two continents with ERP systems and financial systems and the works. If you walked into a software start-up and told them that you're desperately in need of a laptop so if they could just hand them one (wiped/new/etc) they'd pay $200k cash for it, they'd figure out how to make it work.