The movement of pistons and valves in a piston engine cause it to act a bit like an air pump, blowing out the exhaust and sucking at the induction system. The amount of air it is allowed to suck is controlled by the position of the throttle butterfly valve. The engine management system monitors the amount of air passing into the engine, via the Air flow meter, and adds the correct amount of fuel, via the injectors.
There is a small bypass on the throttle butterfly valve to allow the engine to run when it is closed. This is like another small throttle valve, (called the idle speed controller or ISC in Toyota speak). The engine management system monitors the RPM when the throttle butterfly is closed and controls this valve to keep the RPM constant, dependant on engine temperature, air temperature, load etc.
If your engine runs normally except for the high idle speed, then the fuelling is likely to be correct, and the problem will be with the throttle butterfly or idle speed control. Eg main butterfly not closing fully, ISC valve stuck open or being told to stay open because the management system thinks the air-con is on etc.
If the engine runs roughly at idle and just above it is likely to be a hole in the induction system (split hose etc) allowing the engine to suck in air that the management system doesn’t know about. This causes the fuelling to be very wrong (lean). At idle the engine revs will rise until the fuelling is so wrong that it cannot go faster. This problem will seem to go away when the engine is under load because the amount of air entering via the throttle butterfly dwarfs the air via the split. The fuelling is then almost correct.
As the other guys have suggested, check the induction system for split hoses or loose connections, anywhere from the air flow meter to the engine block. If you listen you may hear a sucking noise from the split when the engine is at idle.
The HT system is the most likely cause of a miss-fire, but I doubt this would explain the high revs at idle.