What to wear for a PhD/ MSc thesis defense? Is it better to wear formal clothes for a PhD or MSc thesis defense or can we wear something as simple as a T-shirt?
Almost anything will be fine, provided you feel comfortable on them. The clothes you are wearing will influence the first impression, but you are going to be talking about your project for at least 20 min, and the confidence and clarity will wipe whatever the first idea was. Make sure they are you feel good on them, and don't use them for the first time this day in case they itch or something (specially important for underwear!).

The right level of formalism is very dependent on the culture and setting, but it is probably not so important. It will also depend on whether the event is public or not: if the audience are going to be the people that have been seeing you in normal clothes all year round, or if the public is going to attend and the University wants to shine.
 Of course, a frock and a top hat or just a swimming suit will look ridiculous, but anywhere in the middle would work.

For reference, 
I have been present to two PhD defences in Sweden (where they are quite lax in formalities). In one, the doctorand was wearing plain business-like clothes, slightly more formal than a normal day; in the other, he was wearing a normal shirt, quite less formal than his normal attire. And, for the record, both passed.

Edit:
Jigg is right in pointing that some universities do require a certain dress code. In this case, it will probably be clearly stated by the centre. Being rejected is possible, but extremely unlikely, as it can get the university in all sorts of legal troubles. Also, these regulations can get to absurd levels (the story seems to be a legend, but the third comment may be legit).