While there have been many fantastical proposed origins of this seemingly odd modish style amongst comic artists ---my favorite of which being that most superheroes lost their parents at an early age, so they had no one to tell them underwear goes UNDER your clothes--- the true origin is pretty simple.
According to Julius Schwartz (famed editor of DC Comics from 1944-1986 who edited the most famous of all external-underwear superheroes, Superman), this was simply modeled after the garb of aerial circus performers and wrestlers of the era in which the first superheroes proudly donned their underpants over their tights.
Now, it should be noted here that the wrestlers, circus performers, and superheroes weren't actually wearing underwear, but rather tight underwear-like shorts over their leggings. As superheroes are generally incredibly gifted athletically and perform amazing acrobatic stunts while crime fighting, it was natural enough for this style of dress to get adopted by the earliest superhero artists for their characters.
Two of the earliest major representations of this can be found in Flash Gordon (1934), which in turn was partially the inspiration for the garb of Superman (1938), with the principle difference being the colours of their uniforms and the fact that Superman had a cape (as far as I can find, the first major superhero to wear one).
Of course, if you still want to think of the superhero tight-shorts as underwear, given that Superman and others often wear their uniform under their normal clothes, it kind of makes sense.
Bonus Fact: The original Superman character envisioned by Jerry Siegal and Joe Shuster was not the crime-fighting hero from another world we know today. Instead, they made him a bald bad guy set on ruling the world in the 1933 The Reign of Superman. In this story, a character by the name of Bill Dunn is waiting in a soup kitchen line when Professor Ernest Smalley offers him food and new clothes in exchange for his participation in an experiment.
The Professor proceeds to give him a potion that makes Dunn telepathic; he then becomes a super-man, and tries to take over the world. However, in the process, he kills Professor Smalley, only to discover later that his powers are temporary unless he has more potion to drink, which he can't figure out how to recreate. Ultimately, the former Superman finds himself without his powers and back in the soup kitchen line.
A year after writing that story, Siegel re-cast the character of Superman, this time making him a hero bent on righting the wrongs prominent in society at the time. They also decided to switch Superman's name from "Bill Dunn" to "Clark Kent," after famed actors Kent Taylor and Clark Gable.
If you liked this video, you might also enjoy:
Daven Hiskey writes for the wildly popular interesting fact website TodayIFoundOut.com. To subscribe to Today I Found Out's "Daily Knowledge" newsletter, click here or like them on Facebook here. You can also check 'em out on YouTube here.