Read the book. Mark pages or sections you particularly like. Notice if there are any major points in the book you disagree with. Decide if you can sincerely recommend this book. You could still write the foreword if you can't, but the publisher probably won't use it and you might lose a friend. Steve Jobs went back on his agreement to write the foreword for "iWoz," the autobiography of fellow co-founder of Apple Computer, Steve Wozniak. "I don't know why, because I'm nice to him," Wozniak said to a reporter for the Seattle Intelligencer, "so there must have been something he didn't like."
Tailor your foreword to the appropriate audience. Think about who is likely to read the book, because that is the audience for your foreword. What is this audience likely to want or need? Do your readers want a convenient summary of the book to guide them through a complicated topic? Personal anecdotes about the author? An overview of the field you and the author are working in or studying? A somewhat different take on the events and issues in the book? Reassurance that the author knows what she's talking about?
Make an outline, just like you would for any essay. Even if you decide most of your foreword will be a summary of the book, you need to take a stand on what a reader is likely to get out of this book. Start with a thesis statement, that is, a one or two sentence summary of your conclusion. For example, "John X knows his stuff and this book advances the knowledge of this arcane field we are both engaged in"; or "I saw Suzy Y grow from a cub reporter to a Pulitzer-Prize winner and she's a gutsy broad." This will probably not be your opening sentence. In fact, it may not appear in your foreword at all. It is merely your post-it note reminding you of your point. Back up the thesis statement with three or more reasons, examples or pieces of supporting evidence. Spend as much time as you need to flesh out this outline, because it will get you thinking. Then, put it away and don't look at it for a while.
Try another tack if you decide your outline is unbelievably dull. Imagine yourself talking about the book to someone who doesn't know the author or the subject. Since you are writing this foreword, you probably think the book is worth reading. Tell this imaginary person why. Write an imaginary email to this imaginary person stream-of-consciousness style, without trying to organize anything.
Take the outline and the stream-of-consciousness free writing and see where they come together. An anecdote or story should have emerged from one or the other. If not, do some more thinking. You want a story that will demonstrate a main point--perhaps your thesis statement or perhaps the reason you think the potential reader should read the book.
Write it. Keep it short--shorter than you think it should be. If you get stumped on how to end it, maybe you're finished. After all, your foreword is just the appetizer. Let the reader get on to the main course while he's still hungry.