Yoda encourages Luke to learn from his past mistakes to become a better teacher.
"Lost Ben Solo, you did. Lose Rey, you must not. [...] Pass on what you have learned. Strength, mastery, hmm... but weakness, folly, failure also. Yes, failure, most of all. The greatest teacher, failure is."
"Luke, we are what they grow beyond. That is the true burden of all masters."