I am not Jewish. I came across the following verse (Devarim 22:5):
לֹא-יִהְיֶה כְלִי-גֶבֶר עַל-אִשָּׁה, וְלֹא-יִלְבַּשׁ גֶּבֶר שִׂמְלַת אִשָּׁה: כִּי תוֹעֲבַת יְהוָה אֱלֹהֶיךָ, כָּל-עֹשֵׂה אֵלֶּה
A woman shall not wear that which pertaineth unto a man, neither shall a man put on a woman’s garment; for whosoever doeth these things is an abomination unto the Lord thy God.
I looked online. This prohibition is commonly called "beged isha". To my surprise, I read about the following exception in an Aish.com article:
It would be permitted for a man to wear one item of women's clothing for some functional reason -- e.g. he is stuck in the pouring rain and only has a woman's raincoat.
How did this exception come to be?