
Even in the English language, these things are called by different generic names. The most common names for them are: Undergarment, underwear, underclothes (underclothing), and undies. But they are also called reg grundys (in Australia), smalls (the short term for smallclothes in the UK).
There are also specific names referring to the different types of this kind of garment. Those worn by women are generically called lingerie or intimates (shortened version of intimate clothing). I don't know if there is a generic name for those worn by men.
Undergarments serves a variety of functions. The most basic is probably to keep the outer garments from from being stained by sweat, and for those who live in the colder climate, to provide extra layer of clothing to keep warm. However, today underclothing is not just the basic essential clothing like in the old days. Their functions have developed to include those such as providing extra support, comfort, and protection for the vital parts of the body in in high-impact sports, shaping or emphasizing the body shape, etc.
The oldest underwear ever found by archeologists is known to be 7000 years old. Of course it doesn't look like anything we have today. It was only a loincloth.
By the way, I took the above photo at the King Shopping Center, on Jalan Kepatihan, Bandung. That's how vendors display the undergarments for sale in this market.