The spinal cord is similar to the telephone cable strung along our streets.
Carrying two-way traffic it contains 1) the nerve cell fibers that carry sensory signals to the brain for processing and 2) the 'motor' nerve fibers that carry the brain's orders back to our muscles, glands, etc.
Some sensory signals are so important they are processed directly and quickly right in the spinal cord without the long side trip up to the brain and back to get the only obvious answer.
For example, using cross connections built in locally at the level of the sensory input by Mother Nature we alternately swing one leg forward and the other backwards when walking.