While you are sharing this space with others who are hopefully getting as sweaty as you, there are a few things to keep in mind and a certain etiquette to follow.
We’ll go from bottom to top:
Shoes- any good running shoe should work well for most gym activities. If you are on a basketball or tennis court often you should think about purchasing a pair of specialized shoes. DO NOT wear open toed shoes (sandals), work boots, shoes with no support, etc.
Lower body- yoga pants, exercise pants, running shorts, regular shorts, basketball shorts are all good options. DO NOT wear booty shorts, jeans, slacks, PJs, etc. You might look ridiculous or just be plain uncomfortable. And if you think your pants or shorts may be baggy in the slightest, be sure to wear something underneath!
Upper body- women, unless you want all the attention of every man (and every woman) at the gym, avoid wearing only a sports bra. Tank tops are fine just not really low cut ones, as well as T-shirts (preferably an Instant Fitness “wanna new birthday suit?” T-shirt). Men, wife beaters, sleeveless, T-shirts are all acceptable. Avoid extra baggy shirts and clothes that can get caught in machines. Everyone should leave their job interview clothes at home if attending the gym.
Head- nothing is really necessary here, unless you need to hold you hair out of your face (headband). A hat would be fine if outside but you may not want it collecting all of your sweat and stinking up the place.
All in all, just try to be comfortable, modest, and flexible.