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 Sarvastivada vinaya provides various accounts of the origin of staffs used by monks, with a focus on their use for warding off animals. These include both dangerous predators like tigers and lions and small creatures like spiders and snakes that could be stepped on by wandering monks.