All living beings need to be able to respond to what is going on in their surroundings:
Is there a food source nearby?
How are the current environmental conditions, and is it possible to optimize their impact?
Are predators or other threats present?
Therefore, all living beings need to be able to collect information from their surroundings and to react to this information.
Cortical Neuronal Culture of a Rat © ZEISS Microscopy from Germany
Licence: BY-SA 2.0
In most animals, a nervous system is responsible for these complex tasks.
Even though plants and and some groups of basic animals don't possess a nervous system, they are nonetheless able to collect information about external conditions and to react to them. However, they are more limited in the range of their perception and reactions than most animals which do possess a nervous system.
How nervous systems are capable of fulfilling their important and multifaceted responsibilities is the subject matter of neurobiology.