Ashkenazic Jews of Eastern Europe had a strong tradition that mandated that a baby be named after a deceased relative. It is important to understand that this is a tradition, and is not codified in Jewish law.
No evidence of such a tradition appears in the Bible, in which most names are unique. The custom seems to have started in the first and second century CE, and to have become entrenched by the 12th century. By the 12th century in Europe, we find given names repeating every other generation within families, as a baby was typically named for a grandfather or grandmother. Generally, the child was named for the closest deceased relative for whom no one else in that immediate family was already named. Highest priority goes to the child's mother, if she had died in childbirth, or the father, if he had died before the baby was born.
If any of the four grandparents were deceased, a baby would be named after one of them; otherwise the great-grandparents or, perhaps, a sibling of one of the parents. During the 19th century in Eastern Europe, a girl was typically named after a female relative, a boy after a male relative. Usually, a baby was not given the same name as a sibling who had previously died, although some cases of this have been seen.
Ashkenazim (Jews from Eastern Europe) do not name babies after living relatives. Sephardim (Jews from Iberia and the Middle East), on the other hand, name their children in honor of living grandparents, usually in a fixed order. The first son is named for the father's father, the first daughter for the father's mother. The next son is named in honor of his mother's father and the second girl for her maternal grandmother.