Sometimes it works and sometimes it doesn't, in the Xmen's case it mostly only works on a surface level and it starts to fall apart if you get too heavy handed with it, like the mutant registration act stuff, and the Superhero registration act during the Civil War arc in the comics, the attempts to moralize and compare those with minority struggles tended to be hamfisted at best, and downright farcical at worst. Didn't help that the storyline for Civil War was a convoluted mess either.
The comics themselves though have mostly abandoned the mutants as standins for minority issues, and its been that way for awhile, at least since the House of M arc killed or depowered 99% of the mutants in the world, the Inhumans might be sort of filling that role for the Marvel comics, but that's kind of a stretch and Marvel seems to be keeping most of its comics away from those comparisons at the moment.
As I said, on the surface the comparison can work, as a lose demonstration of how humans fear the unknown or how hatred can cause more problems than it fixes, and how a cycle of hatred requires someone to stand up and be the example of how to break it. In these instances, the mutant or superhero comparisons to minorities can work, as basic moralizing messages, or as basic messages about human behavior or not judging the whole for the actions of individuals.
The issues crop up when you try to make the metaphor more specific, or you try to take it more in depth. This is where the superpowers come in and start to mess everything up. Things like the Mutant Registration Act are too specific, and start to cause the metaphor to fall apart because then you are actually considering that while the metaphor works for low powered heroes like Jubilee, anyone on the upper end of the scale like Magneto and Xavier are basically walking apocalypses and are game breakers all by themselves.
It's partially why Marvel backed off the minority metaphor after the 90's, when they realized that mutants were a pretty shitty standin for minority issues beyond very surface level "don't be a dick" messages. The mutant situation specifically also has a number of other issues, but those mostly relate to the fact that the xmen books take place in the same universe as the rest of the Marvel properties, so you run into a lot of suspension of disbelief issues about why people on Marvel earth hate mutants but seem to be a-ok with Spider man, the Avengers, the Asgardians, etc.
They did sort of try to explain it, but it ended up being really stupid and the company seems to be trying to forget that explanation exists, i.e. humans hate mutants so much in the comics because an ancient sentient fungus exerts subtle mind control powers over humanity to make them hate mutants more because it can't control mutants, or is afraid of them, or something like that, the whole explanation was painfully stupid.