I think it is important to find out as much about the company and the job you wish to apply for before you apply for the job. You should find out before hand how people dress at the company in the department where you want to work. If you show up for a job interview at McDonald's, a construction contractor, or a factory wearing a suit and tie, that will probably count against you (but some contractors or factories might expect a suit and tie). If you show up for an interview at a law office in shorts and a T-shirt, that will usually count against you (but not all law offices are the same). You should where neat and clean cloths that match the environment and culture of the job you are applying for. It will usually help you to dress slightly better than the people that already work there but you still have to dress in a way that does not look out of place.
I once applied for a job as a supervisor at a slaughter house. When I went to the interview I wore a brand new pair of jeans, a new polo shirt, new sneakers, and a clean leather jacket. I sat down with the head of human resources. He stared at me without a saying a word for several seconds and finally asked: "You do know what we do here, right?" to which I replied: "Yes". He then asked: "What if I hired you right now on the spot but you had to start working right now, would you be willing to get those cloths dirty?"