Because "what's in the box is completely different from what's on the label outside."
Open the box set with diamonds.
If it contains rubies, the box marked "Ruby" must be opal, and the box marked "Opal" must be diamond.
② If it contains opal, the box marked "Ruby" must be diamond, and the box marked "Opal" must be ruby.
Therefore, you can open any one of the boxes and know what is in the other two boxes.