The way it works is pretty simple. You enable a custom 404 handler in your web server (in apache, there is a ErrorDocument directive, see your web server docs if you use something else), and point it to a static HTML page. Here's mine: 404.html.
The Apache directive looks like this:
ErrorDocument 404 404.html
Next, into this static HTML, you add a reference to a javascript file at Google. When your server encounters a 404, it will trigger Google to do a search for terms in the URL against the index that Google has for your site, and offer a "closest match" if it can find one.
Google's code looks like this:
<script type="text/javascript">
var GOOG_FIXURL_LANG = 'en';
var GOOG_FIXURL_SITE = 'http://www.khan.org/';
</script>
<script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"
type="text/javascript" ></script>
Now, should an old or incorrect link refer to you, the 404 handler will give them a search to find a better page. For example, there is no /carson link at my site, but here's what you get if you try: carson.
Takeaways? First, any self-respecting website should have custom error pages, even if they are static. Second, Google has a helpful utility that can help your site visitors find what they're looking for and it's a simple copy, paste, edit away from your site too.