I've never been a fan of dress codes because their enforcement always seems to lead to ridiculous situations. In a perfect world, no one would need to be told wearing beach attire to the opening night of the opera isn't the best choice. A 10-year (or 14-year old, for that matter) in leggings isn't going to destroy a company's image in the mind of the public.
BUT what does bug me are the parents (or other adults) who work for United, who are aware of the airline's policies for free flights, and who didn't bother to convey that information to their dependents about the airline's requirements. No airline is required to let its employees and their dependents fly for free. If my sons were given such a privilege, and the airline required a suit jacket and tie, that's what they would wear.
It's too bad the children were embarrassed, but my wrath is directed at the parents who ought to have known better. They deserve the scorn of social media.