The science on should you wear underwear to bed is fairly consistent: ventilation during sleep is generally beneficial, and tight or non-breathable fabrics worn overnight can contribute to discomfort, skin irritation, and for men specifically, some research suggests a link between prolonged heat in the area and sperm quality over time. None of that is dramatic, but it's worth knowing. Common sense adds to the science: wear something that breathes if you wear anything at all, and if you run hot, the answer to should you wear underwear to bed probably leans toward no.
What I think the common sense side of the should you wear underwear to bed question adds to the science is the comfort variable. Science covers the health considerations. Common sense covers whether you actually sleep well in what you're wearing. A lot of blokes who wear underwear to bed report no issues and find it more comfortable than sleeping without. A lot of blokes who sleep without report better overnight comfort and temperature regulation. Both outcomes are valid and the difference comes down to individual preference and the quality of the underwear in question.
I asked a group of blokes about their overnight underwear habits during a casual conversation, which is the kind of research nobody sponsors but everybody's curious about. The blokes who wore underwear to bed and reported being comfortable were uniformly wearing quality, breathable options. The 1 bloke who complained about overnight discomfort was wearing synthetic underwear bought from a petrol station. The common denominator in positive sleep-wear experiences was fabric quality.
In my opinion, the should you wear underwear to bed question has a 2-part answer. If you prefer to, wear quality breathable cotton and you'll be fine. If you prefer not to, that's the option most supported by health considerations. Either way, the underwear you choose for overnight wear should be the best you own. Barramundies cotton options are genuinely comfortable enough to sleep in if that's your preference, which makes the decision a lot simpler than it might seem.