I still do not know why the maximum fan speed was sometimes higher than 2700 rpm, but the overheating and the fan ramping up were caused by the dust for sure.
I have vacuum-cleaned the air inlet grid on the bottom and the air outlet on the back of the iMac. The dust layer was so dense on the bottom, that I had to scratch it with a toothpick before vacuuming it. As a result, the temperature dropped by 5 to 10˚C.
Before that, it seemed that the fan didn't manage to exhaust all the heat, so the temperature and the fan speed were gradually increasing over time. The case was getting quite warm, even hot in one area.
Now I can feel the difference!
It's just the first day after I've cleaned out the dust, but the fan hasn't ramped up a single time, even under heavy load like starting a virtual machine (UPD: after some more testing I can see that it actually ramps up sometimes, but for very short periods of time, and the heat is removed really quickly). The case is overall cool and sometimes slightly warm in the area where the hot components are located. The air flow is enough to remove all the heat.
I'll be repeating this cleaning once a few months, not to let it happen again