Originally posted by Paul Clapham:
But debugging is used to find out why a program is not doing what you think it should be doing.
This certainly is a common use for the debugger, but is not the only one.
It is often productive to use the debugger to step through your new code, even when you do not have a specific bug to find. By doing so, you verify that variables really do have the values you think they should, and that the path through the code is what you expect.
You can't do this for every piece of code, but when you have written something short, but complicated, it can be invaluable.