How to quantify the difference between two xyz files for the same molecule?
What you describe is to calculate the RMSD after superposition. It is not necessary to do a minimization, there is a classic algorithm to get the best superposition directly: Kabsch algorithm. Sometimes, only a subset of coordinates will be superimposed, either because coordinates are missing in one of the structure, or because some parts of the structure show larger differences and interfere with superimposing the similar parts of the structures.

In some cases, where the structures are very different from one another but there are domains of conserved structures, you could also compute differences of pairwise distances and plot them as a distance difference matrix. Distance differences within the conserved domains will be small, while distance differences from domain to domain will be large.

When you do a superposition and RMSD calculation for the first time, it is nice to be able to check the superposition. Many structure viewers have the capability to visualize the superposition while also calculating the RMSD, for example the "compare" command in jmol.