Some of the practices you mention came about because of practical reasons.
Men held the chair for ladies as they sat because the dresses of the time were often voluminous and complicated. That’s also why gentlemen opened car doors and offered a hand to a lady stepping out of a car. Since ladies have the option of trousers, simple skirts, and shorts, it’s understandable that the idea of holding a lady’s chair or opening the car door for her is no longer in common practice.
However, wait for homecoming or prom night, when the young lady is wearing something long, formal, and more challenging to manage. At that point, she’ll likely be very grateful her escort is thoughtful enough to open the car door, hand her out, and then hold her chair for her.
Other customs are more about showing degrees of courtesy, respect, and regard. All individuals are worthy of courtesy. Most are worthy of respect. A few deserve regard.
For men, hats have primarily been practical, providing warmth and protection from the elements. When a gentleman is no longer in the elements, it is no longer appropriate to wear a hat. (Coats, too, should be removed unless the fuss of removing and redressing the coat outweighs the length of the visit.)
Few would quibble about a young man leaving his hat on if he were just stepping inside for something, but on entering a home, a gentleman will show courtesy by removing his hat - he is under the roof of his host. To leave his hat on would imply that his host is incapable of protecting him from the elements. If the classroom is held in high esteem - which it ought to be - then it is a mark of respect to remove one’s hat when entering. The classroom is for learning, a higher purpose than fashion or comfort. To refuse to remove one’s hat in a classroom is tantamount to saying that the perfection of your hairstyle or the warmth of your ears is more important than the enrichment of your mind or the efforts of the teacher to help you become a better person.
Any man who refuses to remove his hat in a house of worship, a hospital, a courtroom, a library, or a private office is not a gentleman. (And as hats as fashion and the necessity of semi-permanent mounting of the hat to the hair for ladies has fallen out of fashion, I would advocate the same rules for them.)
I’m a long time fan of Miss Manners, who knows the history behind the ritual of etiquette and can eloquently explain why what seems to be an arbitrary rule has grounding in pragmatics, compassion, and human sociability.