This is likely to be the more useful answer here. The biggest benefit comes from listing "author of [book you can buy at bookstore]" on your CV or web site. The marketing power of your name being seen by potential employers (or their employees who point to you as the domain expert of a topic). Not from actual royalties past the royalty advance which, as others have mentioned, would be rare.
Of course, the value of that would depend on if you trade on your name; e.g. if you're a freelance consultant.
Even if you're not a consultant but otherwise have a job role that relates to your profile in the industry in some way or other, books are valuable.
I would add that, in many cases, a book is a book. People have short attention spans today anyway so for topics that don't require 100s of pages of code examples and screenshots etc. shorter may be just as good as longer. There are a lot of short books out there these days and they can be just as valuable as giveaways and credibility enhancers as a doorstop is.
Absolutely. When I was starting out on my own I got the opportunity to write for Wrox Press. When talking to clients and going for contracts, it was definitely worth more than being one more guy with an MCSD.
Also, as Dr Johnson noted, writing a book is an excellent way to find out how little you know about a topic ;-)