There is a simple theme in this story, good vs evil. Dr. Grimbsy Roylott represents evil and Sherlock Holmes is a force for good. If you wanted to characterize it more dramatically, you could say that it is a story about chivalry, where Sherlock Holmes is the white knight rescuing the damsel in distress, Helen Stoner from the evil clutches of the dark lord, Dr. Grimbsy Roylott.
Holmes emerges as a hero, slays the dragon (Roylott), rescues the girl and solves the mystery.
Another theme that emerges in this story is one of chaos, which is depicted by the decayed house and Dr. Roylott's behavior, particularly when he threatens Holmes with physical harm if he gets involved with Helen Stoner's case. As contrasted with the world of Helen Stoner, who is engaged to be married and trying to live a traditional, normal life.
Roylott is trying to disrupt Helen's life, he wants to kill her so that he can hide his behavior and keep her money for himself.
In “The Adventures of the Speckled Band” the theme of the story is that evil will be punished by fate if not by man's instruments of justice.
The story demonstrates a kind of karma. The doctor commits evil deeds, and those deeds pave the way for him to destroy himself. He trains the snake to be his instrument of death, and the snake returns to him to kill him.
Holmes comments that a doctor who harms people is dangerous not just because he violates the Hippocratic Oath to do no harm.
When a doctor does go wrong he is the first of criminals. He has nerve and he has knowledge. (enotes pdf text p. 17)
The mystery centers on how Sir Grimesby Roylott, a dotor, manages to commit murder without anyone suspecting. Holmes determines that he has used his reputation for eccentricity, and his animal collection, to accomplish this. He trains a snake to do the murders for him. Yet it is also the training of the snake that causes his demise, because Holmes attacks the sake and sends it back to him.
Some of the blows of my cane came home and roused its snakish temper, so that it flew upon the first person it saw. (p. 20)
Roylott would not have been killed if he had not trained the snake to do his dirty work. He was punished by fate, karma, or his own evil. In the end, he got what he deserved, and Holmes did not really have to play a part in it.
"The Adventure of the Speckled Band" is an example of a sub-genre of mystery stories commonly called a "Locked Room Murder Mystery." Julia was in her bedroom when she experienced the pains and psychological trauma that resulted in her death. Her door had been locked and the windows were covered with heavy iron shutters bolted on the inside. Julia and Helen both locked themselves inside their rooms at night because of their fear of the cheetah and baboon. In a Locked Room Murder Mystery the question is not so much whodunit? as how was it done?
There have been countless locked-room mystery novels and short stories published over the years. The prototype is undoubtedly "The Murders in the Rue Morgue" by Edgar Allan Poe. The following excerpt from a newspaper article quoted in that story describes the locked-room at the Rue Morgue where two women were horribly murdered.
“Four of the above-named witnesses, being recalled, deposed that the door of the chamber in which was found the body of Mademoiselle L. was locked on the inside when the party reached it....Upon forcing the door no person was seen. The windows, both of the back and front room, were down and firmly fastened from within....There was not an inch of any portion of the house which was not carefully searched. Sweeps were sent up and down the chimneys....A trap-door on the roof was nailed down very securely—did not appear to have been opened for years.
In both stories the identification of the perpetrator becomes relatively easy after the detective figures out how it was possible to kill anyone who was securely locked inside a room. In the case of "The Adventure of the Speckled Band," Sherlock Holmes deduces that Dr. Roylott sent a poisonous snake through a ventilator, knowing that eventually it would bite Julia in her bed. In the case of "The Murders in the Rue Morgue," C. Auguste Dupin realizes that there must have been a way for the perpetrator to get inside the locked room, regardless of how thoroughly the police have searched the premises. It turns out that one of the windows was not firmly shut but only appeared to be so.
The theme of "The Adventure of the Speckled Band" can be called "a locked-room murder mystery."
Arthur Conan Doyle has Sherlock Holmes himself state the theme of the story at the moment Holmes and Watson enter Dr. Roylott's bedroom and find him dead.
"It is a swamp adder!" cried Holmes; "the deadliest snake in India. He has died within seconds of being bitten. Violence does, in truth, recoil upon the violent, and the schemer falls into the pit which he digs for another."
Holmes could not have known that by striking the snake and driving it back up the bell-rope and through the ventilator into Dr. Roylott's room he would be causing Roylott's death. This is understandable because, although Holmes seems to have some knowledge about that particular kind of snake, he did not know it be angry enough to bite its owner when it returned to his room. Neither did Dr. Roylott, apparently. He was not prepared from the snake's sudden return and did not have his noose ready to capture it.
Did Dr. Roylott expect Sherlock Holmes to arrive at Stoke Moran to interfere with his nefarious plans for his stepdaughter? Probably not. He may have thought that Holmes would not be sufficiently interested in Helen's distress to travel down there in person, since there was no fee to be gained. He may have thought that he had intimidated Holmes by twisting the iron polka and threatening him. And he felt somewhat protected by the cheetah and the baboon. At any rate, he didn't suspect that Sherlock Holmes was in the bedroom right next door to his own. It was poetic justice that he was killed by the snake he had used to kill Julia and was attempting to use to kill Helen.
Holmes' quotation is referring to Psalm 7:16 in the Old Testament. "His mischief shall return upon his own head, and his violent dealing shall come down upon his own pate."
A young woman named Helen Stoner consults the detective Sherlock Holmes about the suspicious death of her sister, Julia. One night, after conversing with her twin sister about her big day, Julia suddenly reappeared in Helen's room, struggling to breathe, and died soon afterwards. Julia had been engaged to be married and, had she lived, would have received an annual 250 GBP annuity from her late mother's income. Now Helen is engaged to be married. Holmes' investigation of the mother's estate reveals that its value has decreased significantly, and if both daughters had married, Dr. Roylott, Helen's ill-tempered and violent stepfather, would be left with very little, while the marriage of even one would be crippling. Therefore, the main suspicion falls on him.
Dr. Roylott has required Helen to move into a particular room of his heavily mortgaged ancestral home, Stoke Moran. A number of details about the place are mysterious and disturbing. A low whistling sound is heard late at night, as well as a metallic clank. There is a strange bell cord over the bed, and it does not seem to work any bell. There are also Julia's dying words about a "speckled band." Stoner surmises that Julia might have been murdered by the gypsies, whom Dr. Roylott permits to live on the grounds—they wear speckled handkerchiefs around their necks. A cheetah and a baboon also have the run of the property, for Dr. Roylott keeps exotic pets. Helen feels reluctant to sleep in the room.
After Helen leaves, Dr. Roylott comes to visit Holmes, having traced his stepdaughter. He demands to know what Helen has said to Holmes, but Holmes refuses to say. Dr. Roylott bends an iron poker into a curve in an attempt to intimidate Holmes, but Holmes is unaffected as he maintains a rather jovial demeanor during the encounter. After Roylott leaves, Holmes straightens the poker out again, thus showing that he is just as strong as the doctor.
Having arranged for Helen to spend the night somewhere else, Holmes and Watson sneak into her bedroom without Dr. Roylott's knowledge. Holmes says that he has already deduced the solution to the mystery, and that this test of his theory turns out to be successful. They hear the whistle, and Holmes also sees what the bell cord is really for, although Watson does not. Julia's last words about a "speckled band" were in fact describing "a swamp adder, the deadliest snake in India". The venomous snake had been sent to Julia's room by Dr. Roylott to murder her. After the swamp adder bit Julia he called off the snake with the whistling, which made the snake climb up through the bell cord, disappearing from the scene.
Now the swamp adder is sent again to kill Julia's sister Helen. Holmes attacks the snake, sending it back through an air ventilator connected to the next room. The angry snake bites Dr. Roylott instead, and, within seconds, he is dead. Grimly noting that he is indirectly responsible for Dr. Roylott's death, Holmes remarks that he is unlikely to feel much remorse because of it.