system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: why do people get so offended when someone wears a hat at a restaurant or often times even inside? Where did this originate?
gpt
The removal of hats when indoor originates from knights removing their helmets to show that they're friendly and not challenging their king or other superiors. The tipping of the hat (and the salute) also originates from the knights, they would open their visor with their right hand when they met fellow knights. 

During the industrialization, people wore hats (pretty much everyone wore them) as a protection from dirt (people are complaining about pollution today, but in many places it was way worse in the latter part of the 19th century and the beginning of the 20th century). The hats did become quite dirty, and should therefore be taken off and left in the entryway or mud room.