Women and Pants in Halacha
(ה) לֹא־יִהְיֶ֤ה כְלִי־גֶ֙בֶר֙ עַל־אִשָּׁ֔ה וְלֹא־יִלְבַּ֥שׁ גֶּ֖בֶר שִׂמְלַ֣ת אִשָּׁ֑ה כִּ֧י תוֹעֲבַ֛ת יְהוָ֥ה אֱלֹהֶ֖יךָ כָּל־עֹ֥שֵׂה אֵֽלֶּה׃ (פ)
(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.

איכא דאמרי אמר ר' חייא בר אבא אמר ר' יוחנן המעביר בית השחי ובית הערוה לוקה משום (דברים כב, ה) לא ילבש גבר שמלת אשה מיתיבי העברת שיער אינה מדברי תורה אלא מדברי סופרים הוא דאמר כי האי תנא דתניא המעביר בית השחי ובית הערוה הרי זה עובר משום לא ילבש גבר שמלת אשה ותנא קמא האי לא ילבש גבר מאי דריש ביה מיבעי ליה לכדתניא (דברים כב, ה) לא יהיה כלי גבר על אשה מאי תלמוד לומר אם שלא ילבש איש שמלת אשה ואשה שמלת איש הרי כבר נאמר תועבה היא ואין כאן תועבה אלא שלא ילבש איש שמלת אשה וישב בין הנשים ואשה שמלת איש ותשב בין האנשים רבי אליעזר בן יעקב אומר מנין שלא תצא אשה בכלי זיין למלחמה ת"ל לא יהיה כלי גבר על אשה ולא ילבש גבר שמלת אשה שלא יתקן איש בתיקוני אשה

The Bach explains that we rule like Rav Eliezerthat only clothing which is worn for beauty or adornment is forbidden as opposed to clothing worn for utilitarian purposes.

Wearing the other genders clothing is permitted to protect from rain and cold. The Taz concurs.

(ב) אָסוּר לְאִישׁ לְהִסְתַּכֵּל בְּמַרְאָה, מִשּׁוּם לֹא יִלְבַּשׁ גֶּבֶר (דְּבָרִים כב, ה), אֶלָּא אִם כֵּן מִשּׁוּם רְפוּאָה, כְּגוֹן שֶׁחוֹשֵׁשׁ בְּעֵינָיו, אוֹ שֶׁמְּסַפֵּר עַצְמוֹ, אוֹ אִם מִסְתַּפֵּר מִן הָעוֹבֵד כּוֹכָבִים בֵּינוֹ לְבֵינוֹ. וּכְדֵי לֵרָאוֹת אָדָם חָשׁוּב, מֻתָּר לִרְאוֹת בְּמַרְאָה.

(א) שלא תלבש אשה עדי איש - שלא ילבשו הנשים מלבושי האנשים ולא יזדינו בזינם, ועל זה נאמר (דברים כב ה) לא יהיה כלי גבר על אשה... אבל הוא הדין שאסור להם מדאוריתא לצאת במלבושים שדרך האנשים באותו המקום להשתמש בהם, כגון שתשים בראשה מצנפת או שאר כלים המיחדים לאיש (עי''ש בתרגום יונתן בן עוזיאל).

(ב) משרשי המצוה. להרחיק מאמתנו הקדושה דבר ערוה וכל ענין וכל צד שיהיה הכשלון באותו דבר מצוי מתוכו... ועוד אמרו בטעם מצוה זו, שהיא להרחיק כל ענין עבודה זרה שדרכן של עובדי עבודה זרה היה בכך. ואלו שני הטעמים מצאתים בספרי הרמב''ם זכרונו לברכה (בסהמ''צ לאוין מ, מורה נבוכים ג, לז) אחר כתבי אותם.

Rambam writing in his Shu't against the wedding practice of the bride donning a helmet and sword and dancing before the guests. No intention other then entertainment exist here, yet the Responsum states: "One could not think that her being a bride would permit her to transgress a Torah prohibition."

(ה) לֹא תַעֲדֶה אִשָּׁה עֲדִי הָאִישׁ, כְּגוֹן שֶׁתָּשִׂים בְּרֹאשָׁהּ מִצְנֶפֶת אוֹ כּוֹבַע אוֹ תִּלְבַּשׁ שִׁרְיוֹן, וְכַיּוֹצֵא בוֹ מִמַּלְבּוּשֵׁי הָאִישׁ לְפִי מִנְהַג הַמָּקוֹם הַהוּא, (טוּר) אוֹ שֶׁתְּגַלַּח רֹאשָׁהּ כְּאִישׁ. וְלֹא יַעֲדֶה אִישׁ עֲדִי אִשָּׁה, כְּגוֹן שֶׁיִּלְבַּשׁ בִּגְדֵי צִבְעוֹנִים וַחֲלִי זָהָב בְּמָקוֹם שֶׁאֵין לוֹבְשִׁין אוֹתָם הַכֵּלִים וְאֵין מְשִׂימִין אוֹתוֹ הַחֲלִי, אֶלָּא נָשִׁים. הַגָּה: וַאֲפִלּוּ בְּאֶחָד מִן הַבְּגָדִים אָסוּר, אַף עַל פִּי שֶׁנִּכָּרִים בִּשְׁאָר בִּגְדֵיהֶם שֶׁהוּא אִישׁ אוֹ אִשָּׁה (בֵּית יוֹסֵף). טֻמְטוּם וְאַנְדְּרוֹגִינוֹס אֲסוּרִים לְהִתְעַטֵּף כְּאִשָּׁה.

The Rema permits a man dressing in woman's clothing on Purim, since no inanition other then levity exists

The Shulchan Aruch permits a man to remove hair from his private parts if this is the accepted practice among men of the region.

However A)Removing hair is Derabannan, while "lo Tilbash" is biblical.

2) Gentile practice may not set standards of Jewish dress.

Rashba, after quoting the lenient opinion strongly objects "And one who accustoms himself in a forbidden matter, with others following after him, does not change the forbidden into permitted."

Rav Ovadia Yosef (Yabia Omer 10, 14, 6) proposes that the Rashba's objection may only be applicable tot he removal of hair, which is by nature a feminine habit. Clothing styles are liable to change based on popular practice.

Rav Ovadia argues that any clothing no longer unique to either sex can't be included in the lo tilbash prohibition. Female slacks, which differ in style and color tom male slacks would be included in this category.

However Rav Ovaidia is not in favor of women wearing pants for reasons relating to tzniut and gentile practices.

The Tzitz Eliezer writes that the leniency can only be applied where the women's apparel is clearly feminine, such as wearing slacks under a skirt or dress.

Shut Avney Tzedek permits the wearing of slacks in order to protect from the cold, but forbids man tailored jackets because the style is intended to mimic a man's dress.

דביתהו דרבי יהודה נפקת נקטת עמרא עבדה גלימא דהוטבי כד נפקת לשוקא מיכסיא ביה וכד נפיק רבי יהודה לצלויי הוה מיכסי ומצלי