In the Sumerian civilization, the purpose of a ziggurat was to

Ahold back floodwaters.
Bkeep the gods and goddesses happy.
Cirrigate the fields.
Dprotect the people from foreign invaders.