BOSTON (TheStreet) -- The best-laid plans can often go awry. Sometimes, when they do, the result can be pure profit.

Millions have been made from accidental discoveries, proof of the adage that sometimes it is better to be lucky than good.

Famously, chocolate chip cookies were a failed baking experiment. Legend has it that in 1930, Ruth Graves Wakefield, owner of the Toll House Inn in Whitman, Mass., was trying to concoct a chocolate dessert and was pleasantly surprised when the chunks failed to melt into the batter as planned.

The details of this happy accident are sometimes disputed, with an argument made that the accomplished cook's discovery was more premeditated than accidental. What is not disputed, however, is that billions of chocolate chip cookies have been consumed around the world since that fateful day.

Nestle, the Swiss-owned company that originally sold Wakefield's choice of chocolate bits and owns the Toll House trademark, has since grown into a global giant, posting sales of $105 billion last year.

Silly Putty, that beige blob beloved by kids, is another winning product that snatched victory from the jaws of defeat. Since 1950, 300 million eggs of the stuff -- roughly 4,500 tons -- have been sold, according to Crayola, which now owns the brand.

The widely-cited version of Silly Putty's creation (for which there are conflicting accounts) credits James Wright, an inventor employed by General Electric (Stock Quote: GE), with discovering the rubbery mix of boric acid and silicone oil in 1943. Like many chemists during World War II, he was seeking a synthetic rubber substitute amid a shortage of the real stuff. As fake rubber, the goo was a failure; as Wright shopped around his creation, however, a toyshop owner came up with the idea to market it to kids.

Another kid-friendly concoction, Hasbro's (Stock Quote: HAS) Play-Doh, also hit the marketplace after failing in its original intent -- to be a cleaning substance for wallpaper.

Less trivial is the X-ray machine, which revolutionized medicine and has saved countless lives. Its technology was stumbled upon as a byproduct of an incorrectly staged physics experiment with cathode rays.

Penicillin, as most schoolboys can tell you, was an unexpected byproduct of moldy bread. Less likely to be discussed in a classroom is that the chemical phosphorus was first isolated by a would-be alchemist who thought he could chemically extract gold from urine, and instead wound up with a glow-in-the-dark white powder. The versatile chemical (now yielded from far less nasty sources) is used today in toothpaste, shampoo, pesticides and fertilizer.

Warfarin, sold by Bristol-Myers Squibb (Stock Quote: HEW) as Coumadin, a blood thinner used to stave off strokes and heart attacks, was a rat poison until its lower-dose benefit to humans was stumbled upon by researchers. Coca-Cola (Stock Quote: KO) and Pepsi (Stock Quote: PEP) were birthed as medicinal remedies. Plastic was first synthesized in a failed effort to reproduce the shellac once made from beetle husks and Charles Goodyear, as in Goodyear (Stock Quote: GT), made no secret that his revolutionary process for vulcanized rubber was discovered randomly.

The following are five other big products that went from being missteps to life-changing discoveries:

Viagra

Pfizer (Stock Quote: PFE) chemists were developing a pill to treat cardiovascular ailments. In 1991 something came up (literally) that sidetracked those efforts: Test subjects exhibited a rather virile side effect to the treatment.

The pill, later named Viagra and approved by the FDA in 1998, proved a bust in terms of treating heart disease. But the unexpected benefit pumped up its maker's bottom line and set the stage for a brand-new industry.

Today, drugs to treat erectile dysfunction command more than $5 billion a year in sales globally. Of that take, Viagra accounts for about $1.9 billion, but its chief rival in the space, Eli Lilly's (Stock Quote: LLY) Cialis, closing in on parity.

Minoxidil

The discovery of Viagra is only one of the great accidental discoveries to cheer middle-aged men.

For those battling a problem above the shoulders -- thinning and falling-out hair -- the drug Minoxidil, branded by McNeil-PPC, part of the Johnson & Johnson's (Stock Quote: JNJ) family, as Rogaine.

The drug-laced foam was synthesized after Upjohn researchers realized that a blood pressure drug, Loniten, had the side-effect of thickening and darkening hair. Upjohn was later sold to Pfizer and Rogaine was among the brands shipped over to Johnson & Johnson when the company sold its consumer-focused division in 2006.

Applied to the scalp, the drug is not touted as a full-on cure for baldness; its maker does boast of studies where 85% of male test subjects regrew hair after four months of twice-daily use.

Also used by women suffering from hair loss, Rogaine sells roughly $60 million a year, according to health care analysts at Information Resources. Earlier this month, the Food and Drug Administration approved a generic version made by Perrigo (Stock Quote: PRGO) that is expected to hit shelves next year.

Corn flakes

As a Seventh Day Adventist, Dr. John Harvey Kellogg adhered to his faith's vegetarian diet as well as the teachings of the cultish, nutritional hardliner Sylvester Graham, the inventor of graham crackers.

In 1894, while employed by the Battle Creek Sanitarium in Michigan, he began experimenting with ways to make that restrictive diet more palatable and an inexpensive way to feed his charges.

Leaving some boiled wheat unattended, it went stale. Attempting to salvage it by rolling it into dough, Kellogg (aided by his brother Will) found that it tore into pieces and refused to hold a shape. Undaunted, they toasted the flakes and were pleasantly surprised by the result.

After a bit of trial and error, the brothers decided to use corn, instead of wheat, as the main ingredient. The result was deemed tasty enough by patients that Will founded a company bearing the Kellog's (Stock Quote: K) name to sell their corn flakes.

Dr. John, however, opted out of the venture, angered that his brother tampered with the healthful nature of the recipe by adding sugar to the mix. It should be noted that the elder Kellogg wasn't so much worried about obesity or bad teeth; as a staunch practitioner of sexual abstinence, he theorized that his corn flakes would suppress physical urges. Sugar, an aphrodisiac in his opinion, would undo that.

Further revolutionizing how the world eats breakfast, a patient at Kellogg's sanitarium, C.W. Post, used his own variation of the cereal to create his own company and a competing product, Post Toasties.

Microwave ovens

It is hard to imagine the hassle we all went through to reheat lunch or fill a bowl of popcorn before the advent of the microwave oven.

Your beeping buddy in the kitchen owes its existence to a Raytheon (Stock Quote: RTN) engineer who, back in 1945, was experimenting with a device called a magnetron, a microwave -emitting tube used as part of military radar systems. As he tinkered with the device, he noticed a candy bar in his pocket melting.

Suspecting the radiation was cooking his snack, the engineer set out to test the theory. In doing so, Percy Spencer discovered a revolutionary way to cook and goes down in history as the first person to make microwaved popcorn.

Built in 1947, Raytheon's first take on the oven was targeted at commercial uses -- it was more than 5 feet tall and cost roughly $5,000. In 1967, Amana, a Raytheon division, began selling sub-$500 versions intended for at-home kitchen use.

Artificial sweeteners

The discovery and subsequent marketing of saccharin as an artificial sugar substitute might never have happened if there had been an "Employees Must Wash Hands" sign nearby.

In 1879, a chemist by the name of Constantin Fahlberg was working with coal tar. He finished his day's work and apparently headed home for dinner without stopping to wash up.

While dining with his wife, the muck-handed scientist noticed that everything he ate had a distinctly sweet taste. Connecting the dots, he realized his hand residue was the source.

Saccharine's cousin, aspartame, has a similar accidental history. It was discovered in 1965 by chemist James M. Schlatter, who was trying to fashion an anti-ulcer medication. It was later developed and branded as NutraSweet by Monsanto (Stock Quote: MON) before being sold for $440 million to J.W. Childs Equity Partners, a Boston-based private investment firm, in 2000.

—For the best rates on loans, bank accounts and credit cards, enter your ZIP code at BankingMyWay.com.