The word [serendipity] was coined by that curious man Sir Horace Walpole, known today (if at all) as one of the founders of the "Gothic" tale of suspense and terror, but more famously in his own time as an especially elegant and proficient writer of letters. In a 1754 letter to a friend he describes his discovery of some curious Venetian coat of arms and pauses to say that "this discovery, indeed, is almost of that kind which I call Serendipity." And then he explains this "very expressive word" of his own invention: "I once read a silly fairy tale, called 'The Three Princes of Serendip'"--Serendip being an old name for Sri Lanka: "as their Highnesses travelled, they were always making discoveries, by accidents and sagacity, of things which they were not in quest of... (for you must observe that no discovery of a thing you are looking for comes under this description)." The finding of what one is not looking for will be the element of the letter most obviously relevant to what I've been saying so far; but equally important is the phrase "by accidents and sagacity," or, as Walpole puts it later in the same letter, "accidental sagacity."
From The Pleasures of Reading in an Age of Distraction by Alan Jacobs.