Header tags are used to define headers in web pages, these headers allow authors to structure content. Headers are used in many ways not related to the web to explain the meaning of what follows.
Header tags can be thought of as 1 of the most important thing in on site optimisation, what it allows you to do is tell the search engine what the following piece of text is about. Remember a search engine is pretty dumb compared to a human. It does not really understand what your text is about, well that is untrue the do kind of know what the text is about. You can help them along though by suppling good header tags, giving them hints what the text that directly follows the header tag is about. It is a well known secret that header tags are given a lot of weight by the search engines when determining the pages rank for a certain search term. Much like the title tag and the text of the page the header tag is the cornerstone of on page optimisation.
Using header tags is great and all but be careful, since the search engines give that much weight to these tags they also penalise for using them incorrectly. The biggest incorrect header tag usage is spamming, you don't want to load your header tags with keywords. Stick to white hat and keep the header tags useful to your users making them relative to the following content.
The right way to use header tags is to use them as they are suppose to be used, meaning give them a proper structure. H1 is followed by some H2 and H2 is followed by H3. Think of them as groups of content that can each hold a certain number of the subgroups defined by higher header number. I personally prefer to use 1 H1 tag followed by a couple of H2 tags, and in rare occasions I put some H3 tags in. You could go as far as level H6 but I personally only use these very rarely in printed documents never for the web.