I think experience always matters; that is, I don’t think the same person X is going to have the same opinion both before and after the experience.
But it can also give people the illusion that they know more than they do about something—like a one-book expert, a one-episode veteran of this or that experience may think they know all about my reaction to the same thing.
I was furious when my husband wrongly anticipated my reaction to a certain diagnosis because of the way his friend reacted to the same thing. My reaction was almost the opposite, but he listened to his friend instead of to me.
This is why I don’t like speculative questions even in the realm of reality (such as “What would you do if you caught someone breaking into your house?”); I don’t really know, and I might not even do the same thing twice—i.e., not after having the experience once.
But I also think you can give an opinion, a valid and helpful opinion, without having been there yourself. Otherwise doctors would have to have every disease, condition, and treatment, and they’d be a mess. A female therapist couldn’t help much with men’s issues. A celibate priest couldn’t advise on marital stress. And so forth.
And there’d be no such thing as imaginative fiction.
Experience affords a definite advantage in empathy, but it may also limit your view (“Here’s what worked for me, so you should try it”) or even make you deaf to differences. Training should offer wider options. Second-hand experience gives perspective; if you know six people who’ve dealt with, say, a kid’s punitive teacher, you might have better ideas than if you just went with your parental protective instinct.
Permanent conditions can sometimes be experienced vicariously, but probably not without genuine effort. I don’t expect the sort of person who loves to organize potlucks ever to understand the stress I feel when I’m asked to participate in one.