We are comforted by his ability to solve intractable problems, but our love of Sherlock, and science, is tinged with apprehension

More than 75 different actors have taken him on, making him the most portrayed character on film and television ever. Ian McKellen will be the latest to add his name to the roster, playing an elderly Sherlock Holmes in a film set in 1947. The BBC's Sherlock, starring Benedict Cumberbatch, is back on New Year's Day for a third season, and there are rumours of a third film in the Robert Downey Jr franchise.

We can't get enough of Sherlock Holmes. But why? On paper, Holmes is an unlikely hero. He is callous, arrogant, bad tempered, never has love affairs and shuns society. Sir Arthur Conan Doyle described his character as "a calculating machine". Perhaps this is his appeal – Holmes is not just a solver of mysteries, but a mystery himself.

Robert Downey Jr as Sherlock Holmes and Jude Law as Dr Watson. Photograph: Warner Bros

Countless reinventions have played with every aspect of Holmes's character and world – costume, setting, time period, gender, sexuality – but one thing never changes: he is a scientist. His character is a mashup of every stereotype we have ever had about scientists – solitary, introverted, daring, reckless, slightly inhuman, cruel, obsessive, imaginative and brilliant.

The world he was originally created for was one obsessed with science. The Victorian era saw the birth of Charles Babbage's own "calculating machine", a forerunner of modern computers. Many early fictional detectives – Edgar Allan Poe's Dupin, Jacques Futrelle's "Thinking Machine" – were characters who prided themselves on their systematic, unemotional approach to solving mysteries.

Holmes, too, boasts of his lack of emotions – "I am a brain, Watson. The rest of me is a mere appendix" – and his ability to separate fact from theory. "I make a point of never having any prejudices," he tells Inspector Forrester in The Adventure of the Reigate Squires, "and of following docilely wherever fact may lead me." Like Babbage's Difference Engine, there is no personality involved, only the application of a method. "He was," says Watson, "the most perfect reasoning and observing machine that the world has seen."

Jeremy Brett as a quietly mysterious Holmes. Photograph: ITV/Rex Features

But as Conan Doyle well knew, no scientist, let alone a commercial literary character, could survive on cold, mechanical logic alone. The dogged, unimaginative fact collector – a role in which Doyle rather unkindly casts the whole professional police force – is not our only stereotype of scientists. Holmes is also a reclusive, eccentric bohemian, relying on intuition and mysterious flashes of insight.

"See the value of imagination," he tells Watson in Silver Blaze, having conjured a scene in his head and found evidence to justify it. "We imagined what might have happened, acted on the supposition, and find ourselves justified."

In The Red Headed League, he pauses mid-investigation to visit "violin land", where he "sat in the stalls wrapped in the most perfect happiness, gently waving his long, thin fingers in time to the music." He solves the puzzle of The Man with the Twisted Lip by spending a whole night sitting on a pile of pillows built up in "a sort of Eastern divan", smoking, "his eyes fixed vacantly upon the corner of the ceiling".

At other times, he abandons his cerebral methods altogether and opts for good old fashioned fisticuffs. "The next few minutes were delicious," he tells Watson in The Adventure of the Solitary Cyclist. "It was a straight left against a slogging ruffian." At other times, he claims to be "the most incurably lazy devil that ever stood in shoe leather".

Basil Rathbone as Holmes and Nigel Bruce as Watson. Photograph: Hulton Archive/Getty Images

In bringing together these seemingly contradictory characteristics, Holmes is a more realistic scientist, and human being, than any of his fictional rivals. He also lends himself well to adaptation – each new Holmes has a whole suite of personality traits to choose from. Some highlight the narcotics abuse, others the violin playing, some the cutting wit. Downey Jr focuses on his physicality, Jeremy Brett was quietly mysterious, Basil Rathbone outgoing. Cumberbatch's Holmes is brilliantly clever, to the point of madness. But they are all scientists, because what never changes is the method, and the goal.

As Holmes says in A Study in Scarlet, "There's the scarlet thread of murder running through the colourless skein of life, and our duty is to unravel it, and isolate it, and expose every inch of it."

That, perhaps, is at the heart of our fascination with Holmes, and with science. We are comforted by the thought that, however baffling the mystery, there is a solution to be found, and someone capable of finding it. It is reassuring that Holmes uses nothing more than logic, imagination and the occasional street urchin to solve problems, rather than implausible gadgets and superpowers. But our love of Holmes, like science, is tinged with apprehension. We're never quite sure how far he might go in the pursuit of truth.