DTDs are used for validation and entity definition. They roughly specify the syntax requirements for a certain markup language and version.
Validation might be done against a DTD by using a validator. Or, it might be done by the user agent during parsing (as is the case for some validating HTML/XML parsers). Entities defined in the DTD might be made available if the user agent supports that.
A DOCTYPE declaration is the markup language's way (in HTML and XML at least) to reference an inline/external DTD in the document.
Now, as far as browsers' HTML(text/html) parsers are concerned, the DOCTYPE declaration just controls the rendering mode (DOCTYPE switching). The mode will be Standards, Almost Standards or Quirks depending on the version of HTML referenced and whether or not a DTD URI is specified. The actual dtd is not used.
For example, an XHTML 1.0 Transitional doctype with a DTD URI might only put the browser in Almost Standards mode, where an XHTML 1.0 Strict doctype with the DTD URI should put the browser in Standards mode. Further, HTML5's doctype <!DOCTYPE html> will put all browsers in Standards mode and put IE8+ in Super Standards mode (so it behaves a little more like modern browsers when rendering). Generally though, the doctype has little effect on Javascript and DOM support (there are exceptions though, especially with IE8).
For browsers, since you almost always want full standards mode, all you really need is <!DOCTYPE html>. Anything more isn't going to help the browser. However, that doctype is for HTML5. If you want to conform to an HTML 4.01 DTD or an XHTML 1.0 DTD, you must use HTML 4.01 strict or XHTML 1.0 strict with the proper DTD URIs to get full standards mode.
If you want to conform to HTML5, you can test your syntax at http://validator.nu/. It doesn't validate against a DTD and is more advanced than DTD validation. It also reflects HTML 5 better than a DTD could and since HTML5 better reflects what browsers really support, it's syntax checking is more browser-world compatible.
If you want to conform to the HTML 4.01 or XHTML 1.0 DTDs, use the W3C validator. Just note that those DTDs don't reflect what browsers support and only roughly reflect the specs they're for. These DTDs are just more for catching rough syntax errors and for non-browser user agents that make full use of them. They also don't know anything about how browsers behave differently between text/html and application/xhtml+xml.
To read about browser Doctype Switching:
http://www.mozilla.org/docs/web-developer/quirks/doctypes.html
http://www.opera.com/docs/specs/doctype/
http://hsivonen.iki.fi/doctype/