The Church says garments "will serve as a protection against temptation and evil."
Handbook 2: Administering the Church (Salt Lake City: Church of Jesus Christ of Latter-day Saints, 2019), accessed August 3, 2021
The garment is a reminder of covenants made in the temple. When worn properly throughout life, it will serve as a protection against temptation and evil.
The garment should be worn beneath the outer clothing. It is a matter of personal preference whether other undergarments are worn beneath the temple garment.