Dr. Ryloth trained his snake, the “swamp adder” to bite his niece Julia so he did not have to give her the family fortune when she married.
Dr. Ryloth was a sinister criminal. Sherlock Holmes mentions that doctors are the worst criminals.
When a doctor does go wrong he is the first of criminals. He has nerve and he has knowledge. (enotes full text pdf p. 17)
Holmes notes that Dr. Ryloth’s plan was clever, and he almost didn’t figure it out because he was distracted by the gypsies. Nonetheless, there are details to help us solve the mystery. First of all, the bell does not work. Second of all, a strange whistle was heard the night Julia died. Finally, the doctor keeps a variety of strange animals on the property. The gypsy band living there as well is just a red herring.
When the snake comes into their room, Holmes realizes how the doctor used the snake to kill Julia.
He had trained it, probably by the use of the milk which we saw, to return to him when summoned. He would put it through this ventilator at the hour that he thought best, with the certainty that it would crawl down the rope and land on the bed. (p. 20)
It was only Holmes’s brute strength and fast deductive skills that saved them, as the snake came after them in the dark. Holmes saw the snake and was hitting it before Watson knew what was going on. I always find it interesting that Holmes feels remorse when the snake gets angry and returns to kill the doctor.
You can read the full text here: