According to energyeducation.ca, bing.com, and planet-energies.com, the formation of a good oil deposit requires a specific set of conditions:
Source Rock: The process begins with the accumulation of organic matter, such as dead plankton (both zooplankton and phytoplankton), algae, and bacteria, in warm, shallow oceans. This organic matter mixes with inorganic materials like clay and sand that enter the ocean from rivers, forming an organic-rich mud.
Anoxic Environment: The mud must not be exposed to too much oxygen, or the organic matter would decompose quickly. Therefore, environments where oil can form are known as anoxic environments.
Burial and Transformation: Over time, more sediment buries this organic matter, and it lithifies (becomes sedimentary rock), creating organic shale. If this shale is buried between 2 and 4 kilometers, its temperature increases due to its location in the Earth’s interior. This increasing pressure and temperature transform the shale into a waxy material known as kerogen.
Oil Window: If temperatures of the kerogen are greater than 90°C but lower than 160°C, the kerogen is transformed into oil and natural gas. At temperatures higher than this, only natural gas or graphite is formed.
Reservoir Rock: The oil needs a reservoir rock to store it.
Caprock: A caprock is needed to confine the oil.
Geological Structure: A geological or favorable strata is needed to “trap” the oil.
It’s important to note that these conditions take millions of years to occur naturally. Most oil deposits today were formed in the Mesozoic age (252 to 66 million years ago), likely due to the tropical climate and large amounts of plankton in the ocean during this period.
Jorge's answer hits many important points. Here are some others: The process of migration from the source to the place where it will be trapped is critical. The largest fields in the world are found where migration of oil was focused into large traps such as reservoir pinch outs or large anticlinal structures. For any oil to accumulate you must have a source, a migration pathway, a seal and a trap. Furthermore, the timing must be right. For example, if the traps form after migration, they will be full of water only.