On this day in 1837, the House adopted a rule barring members from wearing hats on the floor. This reversed a custom forged during Congresss formative years, when representatives routinely donned hats during debates.The article doesn't give much of an explanation for why, but it was a short, interesting read on the subject.
According to the article, it seems the speaker can "give leave" to a member to wear a hat.
From your article:
Other lawmakers stressed the symbolic value of hats, noting that British parliamentarians donned top hats to show their independence from royalty. Rep. John Patton of Virginia said, Whenever, if ever, our executive magistrates shall attempt to employ any improper influence on this body, let us be found with our hats on.