They play with balls for a living.
That's exactly the attitude that would push the NBA to do something like this. If people think of them as a "bunch of guys dressed like clowns that play with balls for a living (and like Rob said, jump into the stands, fight with fans, and act like 4 year olds), that's not very flattering is it?
If people talked that way about my company, I'd try to improve my image to the public. It couldn't hurt sponsorship deals either to be viewed as a more respectable organization, people will be more willing and proud to be associated with the NBA.
Considering it's not a terrible burden on the millionaire basketball players, why not implement a dress code?