It seems their function is to introduce the idea of fatalism, the idea that we are not masters of our fate. Human fame and glory is temporary. Even Achilles has his weakness.
As the hero falls, he is usually allowed a final comment. Caesar's was "Et tu, Brute?" meaning "Not you as well, Brutus?" That's known as a valediction (means a farewell comment). Shakespeare has many examples: Another famous example is Richard III's last cry of "A horse, a horse, my kingdom for a horse!"