Magnifying Glass for "Search"?

How did a magnifying glass become the default icon for “search” on websites and in applications? Many visual UI metaphors today are starting to get a little stretched and outdated (think of “files” and “folders”), but this one doesn’t tie back to… well… anything that I can think of.

I’ve never used an actual magnifying glass to find anything, ever. Where did this metaphor come from?