Several versions of the staff's origin are given in the Sarvastivada vinaya, but in all of them the staff is recommended to monks by the Buddha in order to ward off animals- either for protection from dangerous predatory animals like tigers and lions, or for scaring off small creatures like spiders and snakes that might be trod on by wandering monks.
The origin of staffs used by monks is described in various versions of the Sarvastivada vinaya.  In all these versions, the Buddha recommends staffs for protection from animals, either dangerous predators such as tigers and lions or small creatures like spiders and snakes that could be stepped on by wandering monks.