A ghostwriter helps another writer finish a book, often without any credit. When credit is given, it is generally secondary. For example, Success Is a Choice by Rick Pitino with Bill Reynolds.
A ghostwriter is not considered a coauthor. Authors are held responsible for ideas and information. A ghostwriter merely assembles all this into prose.
A very successful person, such as a basketball coach or politician, may be a good public speaker. He may be organized, capable, inspiring, and so on, but may simply be inexperienced or unskilled in the art of writing. Writing is a mental discipline. It takes place at usually a much slower pace than talking. Many people can explain something in speech (at the typical rate of 200 wpm or more), but have difficulty maintaining the same flow of words at the average speed at which most people write. Writing comes slowly to most people (10 to 30 wpm), even with the aid of a typewriter.
A number of celebrities or experts have written books with the help of a ghostwriter. Sometimes they (or their publishers) conceal the fact. That is why their writing assistant is called a "ghost". It is as if he is not really there, or at least no one else can see him.
Sometimes a political or ideological opponent of an author will make a big deal about "outing" the ghostwriter.