The custom to wear disguises on Purim in general is based on G-d’s hiding His identity in the Megillah of Esther. The salvation of the Jewish People seems to be accomplished through the actions of people alone, and G-d’s Name doesn’t appear once.
The custom to wear disguises on Purim and to appear as non-Jews is related to our father Yaakov’s wearing of Esav’s clothes when he received the blessings that were due him. It is as if we announce that just as Yaakov only had the outer appearance of Esav, but was inwardly holy and pure, so are all appearances of evil in Israel only external, and inwardly we remain a holy people.
This custom has also been related to a verse in the Torah: ‘And I shall surely hide My face on that day,’ on which the Rabbis comment: ‘Where does the Torah allude to Esther?’ It is said (Dvarim 31) : V’Anochi haster astir panai…’ (And I will surely hide My face…’ ‘haster’ = ‘to hide’ – and ‘haster’ and ‘Esther’ are phonetically alike). From this we learn that hiding one’s face is proper on the day of Esther.
Israel and Amalek are two extremes in the history of the nations. They are furthest apart from each other, but as is sometimes the case with extremes, at times they seem similar to each other. It is the way of Esav, and of Amalek his descendant, to disguise himself in garments which are not his; to talk smoothly, to pretend to be pious and just, while inwardly harboring only evil, deception and cunning. You thus find it said of Esav: ‘For there is hunt in his mouth.’ His mouth and his heart are not equal.
The same trait, but totally inverted, is found among the righteous of Israel. You thus find of David, King of Israel, that he appears like a sinner, whereas in truth he excelled in piety. The same trait characterized our father Yaakov, whose righteousness was so much concealed from all eyes, that even his father Yitzchak failed to recognize his true self until Rivkah revealed his hidden traits and caused the blessings to be given to Yaakov who alone was worthy of them.