Why was the eightfold path created?

The Buddha taught the Eightfold Path as a "Middle way" towards enlightenment between the two extremes of sensory pleasure and asceticism.