Money quote:
The Mishneh Berura (A #91:12 ) states that one must wear for prayers (Shemonah Esrey/Amida) a hat, just like he wears in the street.The rest is here.
That means that since a man normally wouldn't go in the street without his hat, as was the case 70+ years ago, therefore he should ideally approach God in his direct prayers as dressed up as he would be when in public. This is based on "Hikon Likrat Elohecha Yisrael." Which means prepare yourself before God. Dress like a mentch.... The truth is that the entire law is irrelevant today, because we do not normally wear a hat in public, nor in front of important people. The hat thing is gone. It's a thing of the past. If a person wore a hat today it isn't for a mode of dress, but rather some sort of religious mandate that he cannot explain... certainly a hat is not a requirement for prayer and certainly not for Shema or walking in the street...This whole uniform thing is a huge sin. Allow me to explain...