I found the following pages very helpful:
- Compound Words which presents these rules:
the closed form, in which the words are melded together, such as firefly, secondhand, softball, childlike, crosstown, redhead, keyboard, makeup, notebook;
the hyphenated form, such as daughter-in-law, master-at-arms, over-the-counter, six-pack, six-year-old, mass-produced;
and the open form, such as post office, real estate, middle class, full moon, half sister, attorney general.
- Rules for Hyphens Between Words & Hyphens with Prefixes which lists a lot of rules for hyphenating, but whose main thrust is:
Hyphens' main purpose is to glue words together. They notify the reader that two or more elements in a sentence are linked. Although there are rules and customs governing hyphens, there are also situations when writers must decide whether to add them for clarity.