This line from 300 makes me wince, sometimes you have to retreat. Actually a good retreat can serve many purposes, for example by it can take targets out of your opponent’s way you create a vacuum in the wake of an attack. It can also serve a vital purpose in repositioning forces so that they work together rather better.
Against certain opponents a retreat can have devastating psychological effects, for example by convincing them that their position is better than it is and occasionally even baiting them. And I think this might be a particularly effective strategy against an ancient Spartan!
Here’s a nice example of a knight retreat by David Bronstein, his 10…Nb8! energizing his army: