B.B.Woodward suggests one possible reason for pearl production as a result of the mussel's infection by a parasite. He writes the following.
The nucleus frequently consists of a fragment of a brownish-yellow organic substance which behaves in the same way as epidermis when treated with certain chemical reagents. Sand is generally said to be the nucleus; but his is simply a conjecture which has gradually become regarded as a fact; it is quite the exception for sand to be the nucleus; as a general rule it is some organic substance.
In some districts one kind of nucleus seems to be more common than another; at least this is how the different results obtained by observers in different localities may be explained.
Completely spherical pearls can only be found loose in the muscles or other soft parts of the animal.
The Chinese obtain them artificially by introducing into the living mussel foreign substances such as pieces of mother -of-pearl fixed to wires, which thus become coated with a more brilliant material.
How are pearls made Woodward writes further...
Pearls are similar in structure to the shell, and like it consist of three layers; but what is the innermost layer in the shell is placed on the outside in the pearl.
The iridescence is due to light falling upon the outcropping edges of partially transparent corrugated plates. The thinner and more transparent the plates, the more beautiful is the iridescent lustre; and this is said to be the reason why sea-pearls excel those obtained from freshwater molluscs.
Besides the furrows formed by the corrugated surface there are a number of fine dark lines (1/7700 inch apart) which may add to the lustrous effect.
In some pearls these lines run from pole to pole like the longitudes on the globe; in others they run in various directions, so that they cross each other.
Among molluscan parasites the most abundant belong to the stages of Platyhelminthian Worms, which complete the cycle of their existence in some other animal, such as birds, fish, frogs, etc. The history of these is completely known in but few cases.
Still more interesting is the fact that the pearl of commerce has been said to owe its existence to the action of a Cestode larve (Tetrarhychyus), which completes its life-cycle in the bodies of two successive kinds of fish that prey, the one on the pearl oysters, and other on its fellow, as well as on the oysters. The supposition is that, if the embryo worm, on forcing its way into the tissues of the mollusc, carries with it some of the epithelial cells of the latter, and abnormal growth of pearl-secreting cells within the tissues of the animal results, and a pearl is formed, having the parasite for its central point.