Pearls are formed inside the shell of an oyster when a grain of sand (or any other structure) fits into the tissue of the oyster. The oyster is disturbed by this "irritant" and because it want to eject it easily, it secretes gradually layers of what it produce : mother of pearl. But with the only goal, that the irritant get big enough to spilt it back to the ocean.
Thez say you can open 5000 oysters before finding a natural pearl.
It is not surprising that the culture of pearl was quickly developed. Man helps them grow in farms managed by pearl farmers. Thez stimulate the creation of a pearl by inserting a core irritant by an almost surgical operation.
It really began in the late 19th century in Japan, mainly with the researcher Kokichi Mikimoto. While his technique has enable the production of large quantities of pearls, it also helped to control the diameter of the pearl, determined by the size of the core he inserted into the tissues of the oyster.