If you are in a leadership role at the company he/she may not want to open up to you for fear of reprisal even if you two have been friendly. If you two are teammates and you do not have a leadership role they may still not feel comfortable opening up to you because likely they have made comments and if no one picked up on it to discuss with them then they will feel you are complicit or accepting of the situation and don't want to create tension.
There is no harm trying to learn why for sure, but also know sometimes (especially with more senior people) people recognize when their thought processes, methodologies just don't align well with a team or company so they will remove themselves. This doesn't actually mean there is anything wrong with the company/team or with that person, just they recognized the differences and know those would create conflict, tension or struggles for themselves on the team. This is a healthy thing to have happen. That said, it is a very small number of the people that leave usually, more common reasons of leaving are for a lack of recognition, money and/or progress.
If you and the person leaving are both IC's then ask them from a place of curiosity to better understand what they might have seen that you haven't. This is probably the best way to get data points and be non-threatening to the person. When I say non-threatening, I don't mean you literally threatening them, but if you come at them with 20 questions it can start to feel like an interrogation and the persons self defense mechanisms will go up and conversation will go no where.
If you are in any kind of leadership role at the company, come at them from the place of not wanting to lose a good person, but respecting that sometimes people move on for a whole host of reasons. From your perspective you are trying to confidentially understand what the company could do better or change that might make the difference for the next person. Approach it this way, once they tell you if the asks are reasonable say if we made these adjustments would you stay, but don't approach the entire conversation from a place of would you stay. Approach it from the point of view to make sure issues are resolved for the rest of the team and the next people coming in. This is the best way to get data points usually and do so in a way people feel more open to chat. If at the end you ask them if these changes were made would you stay and they say no, then ask why not? That sometimes will open up a more true reason.
*edit: changed a word for readability