Metal sulfides are originally dispersed in the deep rocks of the Earth or those coming from outer space (such as meteorites). They form inclusions in silicates such as olivine and pyroxene. These inclusions are visible only under the microscope.
If hot-, thermal water circulations under pressure (and rich in chlorine, sulfur and fluorine) percolate through these minerals, they can dissolve these sulfides gradually. These waters get enriched in sulfides and migrate towards lesser depths because their density is lower than that of the neighboring rocks.
If the temperature and the pressure decrease below a given value, some sulfides will suddenly precipitate, then forming rather important aggregates, if not centimetric crystals. Metals sulfides that will precipitate first are rich in metals like nickel and cobalt (“high temperature”), then copper and iron then zinc and lead and to finish, antimony and mercury (“low temperature”).
Be aware that other effects often disturb this logic, like tectonics or weathering agents (rainwater, bacteria), which make that each sulfide deposit is often rather unique in its metal sulfide combination.