The oil acts as a thin prism. Light that reflects off of the “back” surface (where the oil meets the road) is refracted into it’s individual colors.
The thinness of the oil covering serves the same purpose as a slit in front of a glass prism.
It’s caused by interference between the light that reflects off the top surface of the oil fim and the light that reflects off the interface between oil and underlying water.
The light that reflects off the oil/water interface has traveled a longer distance than the light that reflects off the top surface of the oil, so, in general they will no longer have the same phase when they meet up again at the upper surface of the oil. Constructive and destructive interference can therefore result, and the type and extent of interference depends on the wavelength of the light, thickness of the film, refractive index of the film, and angles of incidence and observation of the light. Some wavelengths (colors) are enhanced by constructive interference, while others are suppressed by destructive interference. This gives rise to the colors you see.
The same phenonemon gives rise to the colors you see in a soap bubble (light reflects off the outer and inner surfaces of the soap film), and is the basis for antireflective coatings used on eyeglass and camera lenses.
See sources for more detailed explanations.