For example, if I throw two planets to orbit a star at random direction, would they form an orbital resonance?
If the question is "if I throw two planets to orbit a star at random direction, would they form an orbital resonance?" -- then in general, no. A resonance is an integral ratio (1/1, 2/1, 3/5, etc.) between the periods of motion of objects -- i.e., the ratio of their periods forms a rational number. Formally speaking the odds of getting a integral ratio (let alone a strong, low-order ratio, since those are the dynamically interesting ones) if you set the system up "randomly" should be infinitesimal, because irrational numbers are (infinitely) more abundant that rationals.
However, if the orbits of one or both of the planets can change over time, then the ratio between their periods changes, and they can end up in a resonance. (Which is maybe answering the title question.) How often this happens depends on whether the planets happen to start near a strong resonance, and on how rapidly the orbits change. (If the orbit of a planet changes slowly, then it won't encounter new resonances very often; on the other hand, rapid orbital change can overwhelm the effect of weak resonances, so that the planet passes through the resonance without being caught.)
For example, it's thought that Neptune and Pluto were originally not in resonance; but the gradual outward migrations of Neptune (due to various gravitational encounters between planetesimals and the giant planets) changed its orbital period and meant that eventually it reached 2/3 resonance with Pluto, and Pluto was "captured" by the resonance, after which it stayed in resonance with Neptune.
The vast majority of objects in the Solar System are not in resonance with anything else, which is perhaps another way of answering your question. (I.e., in practice it doesn't happen very often.)