We consider self-avoiding rings of up to 1,000 beads and study, by Monte Carlo techniques, how their equilibrium knotting properties depend on the bending rigidity. When the rings are taken from the rigid to the fully-flexible limit, their average compactness increases, as expected. However, this progressive compactification is not parallelled by a steady increase of the abundance of knots. In fact the knotting probability, P_k, has a prominent maximum when the persistence length is a few times larger than the bead size. At similar bending rigidities the knot length has, instead, a minimum. We show that the observed non-monotonicity of P_k arises from the competition between two effects. The first one is the entropic cost of introducing a knot. The second one is the gain in bending energy due to the presence of essential crossings. These, in fact, constrain the knotted region and keep it less bent than average. The two competing effects make knots maximally abundant when the persistence length is 5-10 times larger than the bead size. At such intermediate bending rigidities, knots in chains of 500 and 1,000 beads are 40 times more likely than in the fully-flexible limit.