I wear a hat all day everyday unless I’m in church, praying, eating, National anthem, etc. I was fortunate enough to be close to my great grandmother for a large part of my childhood and she instilled the “no hats at the table” rule in me. I believe it’s probably a respectful thing to do but honestly I mostly do it because it makes me think of her every time I take it off to eat.