How so?
How are anti-nudity laws able to pass strict scrutiny, or why does this one not?
On the first point: public nudity causes harm (I know Micro doesn't agree with this, but since you do I don't feel the need to expound), requiring some form of clothing is an obvious and long standing and (in Western civ.) universal requirement, it can be written in an extremely narrow way, it is easily and clearly enforceable, and it does the very least damage possible while preventing the harm.
Seeing someone's underwear causes no substantial harm (the "thinly veiled genitalia" argument is crap, as nothing on the books prevents someone wearing skin tight jeans that present outlines of genitalia far more obviously than sagging pants, nor are there laws against plumbers crack), it is vaguely written and allows for extremely selective enforcement, and it was obviously written for reasons other than those stated.
It's like the difference between requiring ID to vote, and having a literacy test to vote. One is acceptable and necessary, one is a thinly veiled attempt to harrass people local .gov does not like.