Basically, if you have a doctype on your page, the browser sees it and thinks—OK, this web designer has some clue about what he's doing, so we'll render the page according to the prevailing web standards. If there's no doctype, the browser might decide to display your page in "quirks mode", as if it were built last century, and thus your layout will break in certain ways.
It doesn't really matter which doctype you use. These days, it's common to use the so called "HTML5" version, which is more of a generic doctype:
which ends up like this in the document: