It tells the ECU (DME) where in the 360 degrees of rotation the engine is and how fast it is turning. It's critical to calculating when to inject fuel and when to fire the spark plug.
An S2 won't even try to fire until it's turning at something like 5rpm on the starter motor, which is why they all churn for a second or so, and being a big 4-banger they tend to churn slowly (because each cylinder has quite large displacement). Sometimes poor starting when hot could just be the wiring to the starter or the starter itself being less than optimal and resistances when hot push it over the edge.
I'd say more likely it's something else though and you're doing the right thing starting with the DME relay. It could be one of the sensors is dicky or just out of adjustment so not giving a good signal. They work by counting teeth on the ring gear, in turn using inductance, so they have to be close to the top of the teeth to be able to see the difference between tooth and groove.
Actually now I think it's Turbo that has 2 and the S2 only one. The S2 gets position from a missing tooth and speed by counting teeth per unit time passing it, the Turbo uses grub screws in the flywheel and a missing tooth - I think the grub screws are for speed.