Does anyone know a theory in science that resulted by accident?

Nonsense. Don’t you know that Newton invented the cat flap. He realized that a cat was capable of pushing the flap up, but in order to makeit work properly he needed another, independently acting force, to pull it down again: hence, gravity.

Except that they did not construe their results as meaning that the ether does not exist (and nor did anyone else, initially). It was Einstein who did that, and (contrary to myth) he was not inspired to this belief by the Michelson–Morley experiment. He had already concluded that the ether did not exist from his analysis of the implications of the Maxwell equation. Michelson & Morley just provided a nice, timely confirmation of a conclusion that Einstein really arrived at on the basis of essentially theoretical (and, even, conceptual) considerations.

This question has no clear answer. There is no clear distinction between a discovery and a theory, in the sense that the OP wants. There is no clear way to say what caused the creation of a theory. In general they arose from many observations and trains of thought by the creator. It’s generally not possible to say what one observation was responsible for the creation. It’s not even possible to define “accidental” in any clear fashion.

Lithium carbonate as mood stabilizer for manic-depression.

Agreed - but at least in the case of the Rutherford experiment, the surprising experimental results almost immediately suggested an atomic model in which positive charge was concentrated in a very small volume (vice the plum pudding model which was previously believed).

kekule’s (sp?) dream allowed him to solve the carbon ring linkage model.

Well, maybe, but do you have a cite for long “almost immediately” actually was? I don’t know, but my guess is that it was more like months than minutes.

Sad to say, one of the great myths of science has been debunked. Kekule did report having such a dream, but there were plausible accounts of benzene structure before he had it, and IIRC even examples from him.

I don’t know why Dervorin says that Planck’s original “blackbody” formulation doesn’t fit the category – it’s the first thing I thought of when I read the title. Planck originally proposed the mathematical form as a modelk because it fit the data so well, then went back to explore why.
A similar example is the fitting of the lines of atomic spectra. They originally saw these as possibly fundamentals and overtones, and some spectra seemed to fit this form pretty well. When Balmer came up with a formula that fit (in full knowledge of what had gone before, but which had been “disproved”), he was ecstatic, and thought he’d found a new sort of “Pythagorean” overtone. He had the correct mathematical formula, and even made extrapolations based on it which turned out to be correct (as Rydberg later found), but it wasn’t until Bohr that there was a theoretical basis for it.

The discovery of background radiation.

It occurs to me, also, that although Planck’s theory that energy is quantized was originally proposed just to explain the spectrum of black-body radiation, it turned out to have huge implications in other areas of physics, far beyond what Planck could have originally imagined. Perhaps this is what the OP means by a theory that “resulted” by accident. Although Planck’s original idea of quantization was developed with a good deal of effort, it “accidentally” turned out to be relevant to all sorts of other stuff, and led to the development of the wide-ranging quantum theory that we have today.

Finding the CMB was a surprise to Penzias and Wilson who found it (they stumbled across it) but that there was a CMB was not much of a surprise to anyone. It had been predicted years earlier and there was actually an experiment dedicated to finding it at (IIRC) Princeton.

So, the discovery was accidental but it almost certainly would have been made soon anyway. Penzias and Wilson got lucky.

You’re right - upon checking I find that the experiment happened in 1909, and Rutherford published his atomic model based on the shocking results in 1911. If I’d realized it was that long, I probably wouldn’t have suggested this example.

Actually, if things in the early 20th century were anything like they are today,* it could easily take a year or more between having a scientific paper being written and it actually appearing in print. Thus, despite these dates, you may have been right the first time. Without some specific testimony from Rutherford or his close associates it is impossible to say.

*Or like they were until fairly recently, before the advent of online pre-publication.

I checked a Rutherford biography which suggested that it was about a year before he developed the Rutherford model enough to discuss it.