In the case of taking a test, let’s say you’re answering a true/false question, true represented by 1 and false represented by 0. Let’s also assume you have no idea which one is correct, it’s a coin flip to you.
If you choose True, 50% of the time, the correct answer is true and you’ll have 0 loss, because (1-1)^2 is 0. The other 50% you’ll have (1-0)^2 is 1.
So your expected loss is 0.5(1)+0.5(0)=0.5
On the other hand, if you guess 0.5 (true with a confidence level of 50%), then 100% of the time your error is 0.5, and your mean squared error is 0.25.
In other words, you minimize your expected loss by guessing your true confidence level. This can be mathematically proven to work for any confidence level.
This could be adapted to multiple choice questions by treating each option as a true/false question.
Sorry was that’s very wordy but hopefully you can get the point.
An easier to understand, but perhaps less sensible example would be to do the same thing in a quiz about arithmetic, so 5+5=9 and 6+2=7 is less wrong than 5+5=10 and 6+2=1.