Petroleum is a fossil fuel which got formed by the dead remains of the sea animals. These animals slowly got trapped under soil and clay and more deposits were formed with time. Due to depth, the temperature and pressure raised and over the years they got converted into petroleum oil. Since oil is lighter than water, it did not get mix with water and got raised to the superficial rocks, which did not allow it to pass through them. To obtain petroleum, we have to dig wells to perforate the top rocks and pump up the petroleum oil.
The petroleum oil we get from these wells is a mixture of various other useful substances. Petroleum oil is, thus, refined to separate these useful by-products in petroleum refineries.