For centuries the traditions, laws and culture were transmitted orally from generation to generation.
The schools of the prophets, sages and Rabbis took extensive care to preserve and guard (put a fence around -gezayrot) the traditions. With the destruction of the temple by the Romans, many of the leading scholars were killed. The need was then felt to write the traditions which were then incorporated into the Mishnah.