In the very thin shell of Earth's crust are found many minerals. Because of their purity, scarcity, or social value, some valuable minerals are called gems. The earth uses gravity to generate heat and pressure which sorts minerals by density. Later, chemical bonds form which also create different densities of rocks. Gravity then does more sorting by pulling the more dense objects closer to the earth's core.
Volcanoes are nature's method of naturally refining and sorting minerals.
Precious minerals such as copper, silver, gold, and iron are in solution within the magma which is deep within the earth. In solution, these minerals are in such low concentrations that they cannot be mined until later if the magma were to harden. Water now becomes very important in the smelting process within the earth. Many of the most important mines in the early history of civilization relied upon copper for tools. The cracks, fissures and vents produced by the water were created by the cooling and condensing of the magma.