Unlike the commenter above you, I don’t really agree that it’s completely sanitary, though. I’m just saying that keeping you clean is actually pretty far down the list.
Another thing about whether the floor is sanitary: that changes a lot based on how you use your floor. If you eat, sleep, or sit on the floor often like in a traditional Japanese home, keeping the floor clean is a lot more important.
Keeping your feet clean and protecting them from surfaces are the primary purposes of shoes. Some people need them for support after having worn shoes too often (my parents are in this situation and have a separate set of "indoor shoes" just for this), or some sort of disability that needs those super-wide-sole shoes, but in general they are not for supporting your feet.
Hiking boots can significantly enhance stability and of course walking over sharp rocks becomes trivial.
I also forgot to mention steel toed boots, no slip restaurant shoes, and other injury-protective shoes.
Then you’ve got temperature: hot pavement, cold snow.
Nah, the main function of shoes is (to support your feet and) prevent injury. Cleanliness is second on the list.
[ed.: added braces]
Well, more directly, if you want to be going around barefoot outside, you have to go barefoot for a while in order to harden the skin on the bottom of your feet. It will happen naturally, given enough time, but walking around outdoors with soft feet will hurt like crazy. Bones and muscles are secondary.
In an American context, the primary reason to wear shoes is to prevent parasites on the ground from infecting you through your feet. Shoes are the single most important public health measure in American history, beating out handwashing.
But not on hard floor.