Oil and water don't mix because of a difference between the molecular structure of both substances which causes like molecules to bind tightly to other like molecules, leading to a quick separation between oil and water when the two are mixed. Oil floats above water because it is less dense. These two factors combine to make the two substances separate easily and behave in a predictable manner.
Though oil and water naturally separate from each other, that doesn't mean it's impossible to get oil and water (or other liquids of similar density to water) to mix. Common household items like bottled salad dressing are a good illustration of this principle. While pouring common dressing ingredients like vinegar and oil into a bottle and shaking it vigorously will temporarily cause the two to mix, they will quickly separate. However, through a process called emulsification, ingredients of different density and molecular polarity, including oil and water, can be brought together.
According to Smithsonian Magazine, the temporary union caused by simply shaking oil and water together is known as a loose emulsification. Stronger emulsification can be made by adding an additional ingredient. For example, a smooth salad dressing may include an additional ingredient that binds the vinegar and oil together, such as mustard. In this case, the mustard is known as an emulsifier.