Error 21 is a coin in error. It doesn't have anything to do with the comparitor, although a lot of people get hung up on that. The comparitor's job is to compare the sample coin to the one dropping through. It if matches it allows the coin to drop through the optics, if it doesn't it diverts it back to the coin tray. The comparitor is enabled by the MPU board which only enables it when it is ready for play. When the door is open the machine isn't ready for play, so the comparitor isn't enabled. The LED on the comparitor only lights when it is enabled, so you won't see it lit with the door open. Make sense?
The coin in optics sit right below the comparitor and there's three sets of them (A,B, & C). The coin is expected to pass through them in order and at a certain speed. If that doesn't happen a coin in error (21) will occur. Dust, coin wrappers, and other foreign objects can block the path between the optic emitter and receiver. That is a pretty common cause for the error. Check those, and clean them well. It's best to remove them, that way you can inspect and clean the assembly thoroughly. Most of the time that will fix it, but sometimes an emitter or receiver may have failed. In that case you'll need to replace the optics.