The genizah is a place of deposit rather than a place of worship, and it exists because Jewish law forbids the destruction of writings that bear the name of God.
Why nothing is thrown away
Any worn or damaged text containing the divine name may not simply be discarded, so it is placed in a genizah, usually a room or cavity attached to a synagogue, and left there until it can be buried in a cemetery with due respect. The rule extends in practice to a great range of Hebrew writing, since the name might appear anywhere, so a genizah accumulates not only sacred books but letters, contracts and everyday documents that happen to be written in the sacred script.
The Cairo discovery
That indiscriminate accumulation made one genizah into the single most important trove of medieval Jewish life recovered anywhere. The genizah of the Ben Ezra synagogue in Fustat, old Cairo, held documents deposited across roughly a thousand years, and its recovery from the 1890s transformed the study of the medieval Mediterranean, preserving the ordinary paperwork of a Jewish community that no archive would deliberately have kept. The institution, designed only to avoid a sacrilege, thereby became by accident one of the great preservers of the past.