Aplysia feeding behavior is highly variable from cycle to cycle. In some cycles, when the variability causes a mismatch between the animal's movements and the requirements of the feeding task, the variability makes the behavior unsuccessful. We propose that the behavior is variable nevertheless because the variability serves a higher-order functional purpose. When the animal is faced with a new and only imperfectly known feeding task in each cycle, the variability implements a trial-and-error search through the space of possible feeding movements. Over many cycles, this may be the animal's optimal strategy in an uncertain and changing feeding environment.