The magnets on the flywheel let the computer know where in the cycle of crankshaft revolution, essentially where the pistons are in the four cycles of engine operation (intake, compression, ignition, exhaust), so the computer knows when to fire spark and fuel into each cylinder.
A smooth idle is going to result from fuel and spark being provided at the appropriate time, into the appropriate cylinder. Done correctly, it should provide a glass-smooth idle in an inline-six engine, which is inherently well-balanced.
Note that there is also a sensor on the top of the engine that determines the position of the camshaft. This tells the computer where the cam is at in its rotation.
Remember that in a four-stroke engine, each cam rotates once for every TWO rotations of the crankshaft.