Imagine you're staying in a hotel alone, and you take a shower before breakfast. Out of habit you sing in the shower, and, well, you're not much of a singer. Going to breakfast, you run into the couple in the room next door. The walls are thin, and you can tell by their looks that they're not impressed.
This sucks! Being judged sucks. But there's a fact about the situation that's easy to forget: there are no further consequences. But even knowing that there are no consequences, I think few people would sing in the shower knowing they would be judged. There are, as far as I can tell, three reasons not to:
There might be consequences
Sometimes you do something embarrassing and it does turn out to be a bad thing. Like maybe people make fun of you, or decide you're uncool and stop hanging out with you. That would suck, and you might avoid embarrassing yourself because you're afraid of that.
But even if there are no lasting consequences, I would feel uncomfortable embarrassing myself. I think most people feel the same way. Consequences alone don't explain why people avoid embarrassment.
It's not very nice
Sure, you would get on just fine after being caught singing in the shower, but what about the people who heard you? Maybe they were sleeping and you woke them up, or they just find the noise irritating. In that case, it would make sense not to sing, out of common courtesy. But people feel embarrassed even when they've been completely courteous. Some people feel embarrassed for buying toilet paper, or mispronouncing a word, or having bodily functions in general. It doesn't harm anyone to buy toilet paper, so what else can explain why it would distress someone?
Being judged feels bad
This doesn't supplant the other reasons not to do embarrassing things, but a big factor is that embarrassment deals psychic damage. Embarrassment is bad the same way stubbing your toe is bad. It's a mental version of the pain response.
The similarity to our physical pain response brings up an interesting question: are we better off, feeling this pain?
Mixed feelings on feelings
Physically, there does seem to be value in experiencing pain. Children learn not to hurt themselves, and adults can detect problems they might not have otherwise noticed. One can infer from the presense of our pain response that it has helped us to survive and reproduce as we evolved into our modern species.
Embarrassment seems like another way to keep people from hurting themselves, but in the social sphere. If you didn't feel embarrassed or ashamed ever, then you might annoy everyone and lose all your friends and have a bad life. That would be bad, and the negative feelings may help prevent that.
Besides hurting yourself, embarrassment might keep you from hurting (or inconveniencing) other people. If you didn't care whether others would judge you, you might be selfish and make everyone around you sad. From an evolutionary standpoint, if everyone in your family is courteous, your cooperation would pass on your family's genes more.
You might conclude that, because evolution created it, embarrassment is fine and we should leave it be. But there are many times embarrassment is obviously unhelpful, and we feel bad for nothing. For example, if you feel embarrassed asking for help, you may struggle when other people are perfectly willing to help you. For people with social anxiety, feelings like embarrassment may be paralyzing. (This may be the social equivalent to nerve damage: a pain response that constantly fires without a useful signal.)
A particular question I wonder about is whether some embarrassment is founded on an innate assumption that everyone knows us. In the past, societies were so much smaller that it was rare to interact with someone and never see them again. Trying to look good in front of everyone makes a lot more sense when you see the same 'everyone' all the time.
The assumption that everyone knows us can explain our behavior in other areas of life, as well. We constantly try to change society with individual efforts: individual boycotts, casual volunteering, and arguments in forums all take on society-sized problems and move the needle a person-sized amount. It's hard to tell how much interventions like this help, because as a rule they are unorganized and separate. But as I come up with examples of these individual efforts, I can't help but think they are the glue that holds our society together. In societies like the ones of early humans, efforts like these would be impactful even without collective action; at local scales, they can still be effective today. And as a collective, they make up an unwritten fabric of our world. I don't imagine I would want to live in a world where no one does these things that seem pointless on their own. Nor would I want to live in a world where neighbors sing through thin walls, TMI is frequently shared, and possible annoyances are just ignored.
Different people deal with embarrassing situations differently; it's unclear to me how one's natural responses to it can be changed. But just like we take interventions against headaches or joint pain, there is surely some amount of embarrassment it would be best for us to avoid. Our instincts are amazingly suited to a neolithic world, but in the 21st century, we should try to adapt to a world with strangers.