The main advantage of not destroying the enemy utterly is that there generally is no benefit from utter destruction while there is a real cost from committing resources to it.
For example, pursuing fleeing enemies means detaching a force to follow them which means the pursuing force will not be available for anything else. Unless you have an abundance of fast troops, this is usually bad use of resources. Fast troops are generally more useful for screening and reconnaissance and committing them to vanity projects will potentially leave you exposed to enemy stratagems that otherwise would have failed. A policy pursuing fleeing enemies also gives the enemy a trivially exploitable and predictable opportunity to lure the pursuing force into an ambush. Which is even worse use of resources.
Similarly every enemy that flees or surrenders instead of being killed is one less opportunity for your forces to take casualties. Psychologically such "total kill" policy works two ways. It promotes desertion and lack of resistance, which is good and works well for fast campaigns. But if the fighting drags on, the campaign becomes prolonged, you will be fighting enemy that is committed to fighting to the death. This usually translates to high morale for them and high casualties for you. Manuals since ancient times have strongly advised to avoid situations where enemy can't escape for a good reason. So a "total kill" policy should always be targeted on only those cases where either making your potential opponents choose not to fight at all is a priority or you are already fighting fully committed enemies.
Historical examples would be Mongols needing to minimize time consuming siege warfare to fully exploit their superior mobility or religious or ethnic warfare that might already extermination wars, anyway. Asymmetric warfare between superior occupying force and a resistance movement can sometimes devolve into this, if the occupation prioritizes scaring people into not supporting the resistance. But as this causes heavy collateral damage, it is rare unless the occupiers have lot more area under occupation than they can or want to control.Germany had such situation during the World War 2.
One consideration is that the enemy soldiers are also resources with value and dead humans are usually nearly worthless or even have negative value as you need to commit forces to disposing of the bodies. The exception would be if the dead soldiers have value as food or trophies. But generally armies are too large for that value to remain worthwhile if you kill everyone. So this is only realistic for skirmishes or asymmetric warfare where the defeated force is small in relation to the victors.
Generally almost all of the value of the captured soldiers is in their ability to work and they are used as forced labor or sold to slavery. There is also real political value in returning prisoners of war after the war or even exchanging or selling them back during it. This is true even if the "enemy" is supposed to not exist after the war. In that case you have supplanted the enemy and the value of enemy soldiers you did not kill is now your resource. These value considerations do apply to letting fleeing enemies get away, not just on what to do with captured enemies. If your best option is to let them go, why spend resources capturing them?
From the viewpoint of military strategy you should also remember that the goal is usually to destroy the ability of the enemy force to oppose you, not to kill soldiers. As others have noted killing everyone is actually very difficult, so there is almost always several vastly easier methods to achieve your goals without killing everyone. The big exception in history is siege warfare, where you already may have the enemy surrounded and the fighting will likely get ugly and chaotic anyway. In such situations massacres have happened.
I hope this actually contains an answer to the question. In any case it should be useful in giving some context.