The most basic function of the hyphen is to indicate linkage of two (or more) things that would otherwise be separated. Thus, its most common use is at the end of a wrap-around sentence, in which a word is broken between syllables.
The hyphen also acts to group words that normally appear separately, but are being treated as a single entity. For example, fractions (one-third, four-fifths), compound adjectives (private-sector employment, the 22-year-old candidate) and many compound words that would otherwise join with identical letters (co-operate, re-emerge).
One of the most common areas where confusion arises is when a word or phrase can be used one way without the hyphen, and another way with it. "Thank you" is a frequent example. To explain why requires a quick review of some basic parts of speech and what they do in a sentence. A sentence has to have a subject (generally stated, but in this case, sometimes implied) and a verb (action). It often has something that receives the action or that explains it further (object -- either direct, indirect or prepositional -- but that's more than you need to worry about right now!). When I write "thank you for your help," the implied subject is "I" -- the meaning is that "I" am doing the action of "thanking" and the recipient of that action is "you". "Thank" and "you" are doing very different jobs. But, if I want to explain that "I sent thank-you notes to the people who helped me," it's an entirely different situation. "I" am still the subject, the action is "sent". "Notes" is the thing that was sent, and by way of giving more information, the type of "note" has been described using an adjective, in this case two words that are behaving like just one, by way of our friend, the hyphen, that links them, "thank-you."
Other examples: "the mayor was ill-at-ease," "I need to pull out that tooth" v. "the troop pull-out went without incident," "the first-time traveler" v. "the first time-traveler*," and "the book she read left her with that there's-something-under-the-bed-that's-about-to-grab-your-ankle feeling."
One further application is the suspensive hyphen: when a series of similar phrases are used as adjectives, the suspensive hyphen allows the writer to eliminate repetition -- "the annual report included the one-, three-, five- and ten-year performance of the company's stock."
* Courtesy of Business Grammar, Style & Usage by Alicia Abell, p.34