As always, this is an interesting topic!! Because Pablo Hidalgo personally defined attachment in Star Wars/re: the Jedi as, “that sense of ownership, that sense of entitlement to someone else in your life“ and a psychologist (when looking at Star Wars through the lens of psychology--and vice versa) defined it as, “Non-attachment refers to allowing things to be as they are.” and that really, really makes a lot of sense within the Star Wars narrative.
I think a lot of people assume that attachment means any kind of bond to anyone else, but we see that’s not true--Depa says that feelings are to be cherished, Obi-Wan says of course they’re allowed romantic feelings, and in that Character Encyclopedia about Mace and Depa’s relationship, it’s described as:
Attachment isn’t about caring about someone or having a close bond with them or working to help them, it’s about being entitled to having that in your life (regardless of if they just want to leave or if they’re dying and you want to literally stop death itself), it’s about being unable to accept otherwise.
What Yoda has learned, after training and watching so many of his family pass into the Force, over TWENTY-THOUSAND OF THEM (as there can’t be that many still alive that he’s helped train) is that eventually death comes for them all and, as someone who is a psychic space wizard, he touches the Force every day of his life and feels it when people return to it.
After watching 20,000 of your grandkids die, yeah, you learn to accept that death is a part of life, trying to fight against the tide to an unreasonable amount--ie, yes, Anakin, if you think Obi-Wan is going to die in battle, watch his back, if you think a Senator is going to die in childbirth, encourage her to go to a doctor, but don’t obsess over it, don’t feel that the galaxy owes you that person in your life, don’t become so invested in someone else that you will literally burn down the rest of the galaxy if they die, if they’re going to die and you can’t stop it, work towards rejoicing in what time you have with them, because joy is better than suffering--that is what Yoda’s life has taught him.
When you live 800+ years, you realize that you’re just a small part of a greater galaxy, that you should enjoy what you have while you have it, that life is always and forever fleeting, the only thing that is forever is the Force. Of course he’s learned that there’s joy in that, in becoming part of something that’s forever.
Because wrapping yourself up in someone so much that you’re ripped apart when they die for reasons beyond your control (because people do eventually die) really is a tragic thing and only leads to suffering. Accepting things as they are (ie, that some things can be changed, but some cannot) leads to joy. It’s not always easy, Yoda himself struggles with it still sometimes (I DID NOT ASK FOR SAD GRANDPA FEELINGS, THERE IS ANOTHER) but ultimately letting go and accepting things and being selfless are rewarded in the Star Wars narrative.