Says the Oxford English Dictionary:

Serendipity

[f. Serendip, a former name for Ceylon + ITY

A word coined by Horace Walpole, who says (Let. to Mann, of Jan 1754) that he had formed it upon the title of the fairy-tale 'The Three Princes of Serendip', the heroes of which 'were always making discoveries, by accidents and sagacity, of things they were not in quest of'.]

The faculty of making happy and unexpected discoveries by accident

...1880 E. SOLLY Index Titles of Honour Pref. 5 The inquirer was at fault and it was not until some weeks later, when by the aid of Serendipity, as Horace Walpole called it --that is, by looking for one thing and finding another-- that the explanation was accidentally found.