I think this is especially true of the people in our lives. People come into your life every day. Some for a minute, some for an day, some for a year, and some, perhaps, for a lifetime, or at least close to it. People also leave your life every day, in the same pattern. I think the key thing to remember is, you never know who will follow which pattern. I've met some awesome friends in the following situations: waiting to board a flight at LAX, standing outside a hostel (way back when I did that hostel thing!) waiting for my tour to depart, sitting at the bar next door because I just felt like getting out of the house but had no other plans. Lets ignore that this last one may make it sound like I need to drink more non-alcoholic beverages. The point is, I could just as easily not have struck up a conversation with these people who are now a regular part of my life. Or they could have ignored me. I didn't talk to them to make new friends specifically, I talked to them and happened to make new friends. Similarly, I've watched people I thought I'd lie on my death bed with walk out of my life. In other instances, I've walked out of theirs.
You never know who will enter your life, in what capacity, or for how long. Sometimes, you never understand why they exit your life, and you have to accept that you probably never will. Sure, you can ask them. They may or may not answer, and that answer may or may not be legitimate and satisfactory to you. You can try to work on troubled relationships or friendship, and it may or may not work. You can attempt to keep in touch in hopes that it's just a rough spot, and it may or may not be. But in the end, things happen that we won't ever understand. Period. And we have to let them go. We have to stop trying to understand them. We may be able to summarize it as "that's part of the plan" or "karma will work its magic." Or maybe we'll look back on it one day and think, "ahhh that taught me such a valuable lesson". But that's about as much explanation as we'll often be able to conjure up.
One thing's for sure though - the more you struggle to understand it, the more frustrated you'll become. The "needing to know why" may consume you more than the effects of the actual situation. Sometimes, you just have to say "it is what it is". People tease me now, because this is my response to so much in life that I previously tried desperately to control, and have now realized I can't. It doesn't make it hurt less, but it can helps me move on and get through it. You can't control life, or other people. You can't necessarily even control who you love or like, or who you dislike for that matter. So don't let that person or that situation, that you have no control over, have control over you.