Why is there such a difference between online and offline lap times?

Should be the opposite. There’s greater rubbering in the race, so you will have more grip if you are on the same tyres.

Track rubber resets when the race starts.