Introduction
Of all the gems available for sale, opal is by far the most difficult to understand. This is because of the large variety of opals available, which can look extremely different. Figuring out, therefore what exactly opal is, can be baffling especially to someone who is just looking for a pretty rock to impress their partner.
Definitions
The classification of opal is made more difficult in the fact it is not even a mineral! It is officially known as a mineraloid, being described as a hydrated amorphous form of silica. Amorphous meaning undefined shape, hydrated meaning having water included in its chemical structure and silica being a mineral composed of silicon. Thanks a lot official definition for not really saying anything!
What we can say is that opal is typically some silica (the substance that makes rock rocky) which has been deposited in gaps in rocks. If a crack opens up, some opal may possibly accumulate there.
What do you mean by deposition?
If you can think back to your high school science class, maybe you were given the task of growing salt or sugar crystals.

If you don't remember, or have never done the experiment, basically all you do is dissolve some sugar or salt into some water, heat the water, dissolve more sugar or salt in, until you cannot dissolve any more. Then dangle a string in the solution and let it cool. By doing this, you can grow a big sugar or salt crystal!
What works with salt and sugar also works with silica. The major issue however is... have you ever tried to dissolve a teaspoon full of sand into a glass of water? This process takes a very long time. Millions of years in fact.

Anecdotally, it seems that if the sand dissolves at all, it doesn't move far from the spot it dissolved before it precipitates out again. This is important for opal cutters because the rough (uncut opal) that they get typically has a lot of sand attached.
Anyway. The dissolving and depositing of silica from stuff like sand is how opal tends to appear in rock cracks.
There are many different types of opal, but this is a topic for a different discussion.