Shaykh Yasir Qadhi deals with verses 80 to 82 that deal with the following topics:
If one needs something to be blessed, one should ensure for it to be associated with Allah.
Parents of the boy who was killed were righteous and their love for their child would have negatively impacted their righteousness and relationship with Allah.
The rewards of losing a child.
Attributing negative to self and positive to Allah SWT.
“And as for the lad, his parents were believers, and we were afraid he would impose on them insolence and disbelief.” “So we did intend that their Lord should change him for them for one better in purity and nearer in affection.”
In this verse, the Qur’an refers to the secret of the second event - the murder of the lad.
“And as for the lad, his parents were believers, and we were afraid he would impose on them insolence and disbelief.”
If that boy continued to live then he would have been a source of disgrace or creation of one for his faithful parents.
Finally, in order to remove any doubt from Mus AS, Khidr assured Musa AS that he did not perform any of the deeds at his free will, but it was the command of Allah that he followed. And, this was the mystery that Musa AS could not bear patiently.