There are a couple of things, its likely that their is some internal damage, there are some wipers inside the lens that send position information to the lens, and if they were bent or not making contact, then the lens does not know what position its in.
The camera sends a command to the lens telling it where to focus something like move to focus at 5.2 ft. The lens compares the position of the wiper on the resistor by measuring the resistance, and findsthe point where the internal data table says "X" resistance is 5.2 ft. (I've simplified the process to give the general idea). If the circuitry cannot read the resistance due to dirt or a damaged part, it will hunt.
There are several other things that can make this happen, the flexprint that moves is also a frequent failure point.
The plastic case can be replaced for a few $$, but the lens glass will almost certainly be out of alignment, and AF accuracy will be off.