The Sages state: “Ĥanuka candles should be placed at the doorway, outside the home. One who lives on an upper floor places them in the window facing the street. In times of danger, it is sufficient to place them on the table” (Shabbat 21b).
In the past, most people lived in single-story homes. A doorway led either to the street or to an enclosed courtyard with an exit to the street. The Sages ordained that people should light at the exit to the street, in order to publicize the miracle of Ĥanuka. They added that the candles should be lit to the left of the entranceway. This way, people passing through are surrounded by mitzvot, with the mezuza on the right and the candles on the left (Shabbat 22a).
The Sages further stated that ideally the menora should be placed no lower than three tefaĥim from the ground and no higher than ten tefaĥim from the ground (between 9 and 30 inches). The reason for this is that if it is placed higher than ten tefaĥim, people who see it would think it is meant to illuminate the entrance to the home, since when people used to light candles to illuminate their homes, they would place them in their entranceways at a height of above ten tefaĥim. However, if it is placed lower than three tefaĥim, which is very close to the ground, people would think that the candles were placed there only temporarily, and would soon be moved to an area that needs to be illuminated. Only when the menora is placed at a height between three and ten tefaĥim is it clear to all that it was lit to fulfill the mitzva, and in this way the miracle is publicized. In any case, be-di’avad, if one lights Ĥanuka candles lower than three tefaĥim or higher than ten tefaĥim, he has fulfilled his obligation. However, if one lights candles at the entrance to his home and places them higher than twenty amot (about 30 feet), he has not fulfilled his obligation. In such a case, the candles are so high that people are not likely to see them, as people do not normally look at things that are so high (Shabbat 21b; sa 671:6).
Some people lived on upper floors and exited through the residence on the ground floor. They did not have their own doorway to the street, and had they lit at the entrance to the ground-floor residence, no one would realize that the candles were theirs. Therefore, the Sages instructed them to light in their upper-floor home, in a window facing the street.
In times of danger, when Jews feared harassment from non-Jews, the Sages stated that one should light Ĥanuka candles on a table inside one’s home. The miracle would be publicized only to the individual and the members of his household.