It means to make yourself funny in front of others. The origin of the word is “just hair”, meaning not covering your head. In old times women should always cover their hair with a shaul when going to church, and if it slipped and the hair would become visible, it was a shame. Thus, to make something that you feel ashamed of, something that makes others laugh at you.
Опростоволосился на экзамене.