I heard a story some time ago about a mathematical mistake that turned out to be very helpful:
The story goes that a fellow named Drude was trying to concoct a model for electric conductivity, but he made an error (related to Poisson statistics) which put his final result off by a factor of two. Fortunately for him, this error made one of the central predictions of his theory almost exactly consistent with experimental data. This stimulated much interest in his model.
Drude's model was fundamentally wrong both because of his factor-of-two mistake, and because he didn't know about quantum mechanics (as it hadn't been invented yet). After quantum mechanics was introduced, somebody else revisited Drude's model with quantum corrections, and it turned out that this modified model was essentially right (no missing factors of two). The two problems with the original Drude model essentially cancelled.
Drude's technically incorrect model was the conceptual foundation that eventually led to the correct model. Since he couldn't have known about quantum mechanics, it was fortunate that he screwed up the math, as otherwise his model would be appeared to be inconsistent with experiment, and no one might have taken notice.
(My version of this story comes from Ashcroft and Mermin's "Solid State Physics".)
What other examples are there from history of a mathematical mistake being made in such a way as to be very useful?