The nervous system detects changes in the environment (stimuli) through sensory receptors, processes the information in the brain and spinal cord, and generates an appropriate response through motor neurons.