This scream is mentioned several times throughout the story, first when Holmes and Watson are introduced to Dr. Roylott and again when Helen Stoner describes the events leading up to her sister's death. This repeated mention of the scream foreshadows its crucial role in the climax of the story, where it serves as a warning to Helen and a vital clue for Holmes.
The scream becomes associated with danger and violence, ultimately leading Holmes to deduce that the scream is not merely a cry of anger, but a signal to the deadly "speckled band" - the snake.
This foreshadowing creates suspense and allows the reader to anticipate the role of the scream in the unfolding events.