According to my understanding, for an orbital resonance to be stable, there must be at least three circumstances present:
- The forces on the bodies in resonance have to cancel out over time,
- The momentary forces shouldn't be that high that the orbits are changed significantly,
- after a perturbation, the bodies should pull each other back into resonance.
For example, the Trojans are in a 1:1 resonance around the Lagrange points of Jupiter, and the Galilean moons of Jupiter are in a 4:2:1 resonance. A 2:1 resonance wouldn't be stable at it's own because the gravitational forces would always apply at the same point, but the perturbances are cancelled out by the third moon, and the outer and inner moon are in a stable 4:1 resonance.
In general, a resonance can be stable, if the encounters of the objects are equally distributed, so imaginary lines between these points have point symmetry / a regular shape (for example a straight line across the orbits (3:1; 3:2), an equilateral triangle (4:1; 4:3), a square (5:1; 5:2), a pentagon or pentagram, etc.) But, the closer the orbits get to each other, the more unstable they get, because the deflection gets bigger, so those resonances only work if the bodies aren't too massive. 2:1 resonances can be relatively stable too, but without any other resonance preventing it, the eccentricity will rise over time and one of the bodies may be ejected. However, orbital resonances are only stable in certain circumstances, because if the eccentricity and/or the inclination are too high, the forces don't cancel each other out enough. But there still are some configurations in which highly inclined and eccentric orbits are stable.