I can't tell you for certain why the author decided to end the story this way, but I can explain my interpretation of why this makes the story more powerful. What the author intended may not be the most interesting or answerable question anyway. Because we're talking about justifying why a person 'should' have died, and some of this is going to sound horribly callous, I feel compelled to add a disclaimer that I'm speaking purely from the point of view of analysing a story.
Sometimes, a single unrecoverable day can have the most impact on a person's life.
Let's imagine that Mr Lamb hadn't died. Probably Derry would have kept coming back and talking to him, and perhaps changed a lot as a person. But every friendship, every relationship, has its ups and downs. Maybe they would have quarrelled and, in taking leave of Mr Lamb, Derry would have returned to his old attitude to life. Maybe the old man would have lost some mystique in Derry's eyes, his wisdom would have seemed like more platitudes, and Derry would have stopped listening. Certainly there would have been other influences (such as his mother, as we see in Scene 2), trying to persuade Derry not to have anything more to do with Mr Lamb.
But now, with his newfound friend dead, there's no opportunity for Derry to see new facets of him or argue with him. He will always remain in the boy's mind associated with that one conversation. There's nothing he can do now to lower Derry's opinion of him - and conversely, Derry will never know what more he could have said to inspire him. Maybe Mr Lamb's death will inspire Derry to change his lifestyle in honour of the old man, more than he would have done for a living friend. Maybe this is the first time someone Derry knows has died. What's certain is that this day will always linger in the boy's memory, in a more visceral way than it would have from anything further Mr Lamb could have said.
See also: one of the discussion questions at the end of the text you linked.
Will Derry get back to his old seclusion or will
Mr Lamb’s brief association effect a change in
the kind of life he will lead in the future?
As well as making Derry more likely to remember and act on the wisdom of Mr Lamb, his unexpected death may also remind Derry of his own mortality. Mr Lamb had lived a long and apparently fulfilling life, and even though it was cut off in an abrupt and unexpected way, some of his memories and wisdom still lived on due to his effects on others. Seeing him dead might shock Derry into realising that one day he too would be dead - and that if he continues avoiding his fellow humans, he'll never have any legacy or way of living on. We all die in the end, but it's better to die mourned and satisfied than unloved and forgotten.
Finally, from a completely out-of-world perspective, killing off a character adds pathos to the story. If the last scene was removed, the tale would have been interesting in a more intellectual way: watching two characters discuss life and their respective problems is interesting and thought-provoking, but it lacks the emotional gut-punch of the ending, which perhaps makes the story more effective and memorable to many readers.