Most gym have insurance carriers and rules that say proper footwear is required. The definition of proper footwear gets skewed. In Texas, lots of folks think that means flops. Up north, tennis shoes / sneakers. Now, with esoteric shoe designs...well hard telling.
I've been wearing wrestling shoes for decades. They're flat; they stick to the floor; they're comfy; they're supportive in right places; they don't tear up gym benches.
Technically, you're supposed to wear shoes, but...many folks prefer to do squats, deadlifts, or the stairs, shoeless. I hate doing stairs with clunky shoes because my calves get so pumped up.
Sanitation is another thing. If someone has a foot fungus...should they be spreading it around?
Some gyms are stricter than others, even in the same chains. E.g. LA Fitness in Lewisville doesn't tolerate no shoes, nor idiots doing stupid stuff on the stairs (actual stairs). LA Fitness in Carrollton...nobody cares about anything and idiots jump rope in the free weight area and so on.
I'm not sure not wearing shoes is a health risk. I mean, the gym is full of germs. Just the nature of the place.
Feeling snug / flat to the floor does help in leg and back movements.