Have you ever made a hard cider and noticed a rotten egg smell? That is hydrogen sulfide (H2S). Saccharomyces cerevisiae, the most common yeast used to ferment hard cider, wine, and beer, can create hydrogen sulfide through 3 main pathways(1). One pathway is through enzyme conversion of sulfate and sulfite. A second pathway is from amino acids, specifically methionine and cysteine. Apples naturally contain small amounts of these amino acids. However, these amino acids can also be formed from the reduction of proteins. These reductions usually occur because the yeast needs some nutrient that is lacking. It finds a way to obtain this nutrient by breaking down other compounds, which creates the hydrogen sulfide. The last pathway is through elemental sulfur. This is usually a spray added to the tree or grape vines as a pesticide or protection against powdery mildew in grapes.
The yeast strain often has a big impact on the production of hydrogen sulfide. Some are prone to produce large amounts while others are not. A common practice is to treat juice with nutrients, especially nitrogen, to avoid the production of hydrogen sulfide. However, if the cause is elemental sulfur, you should seek to avoid spraying near harvest. If the creation is from lack of nutrients, you might want to consider a different yeast strain. Adding too much nitrogen can be just as bad as not having enough. Ultimately, if you do generate hydrogen sulfide, you can rack and aerate the cider. Take care though as this can create problems through oxidation of other compound. Potassium metabisulfite may be a better option. Copper sulfate is also a potential treatment but all of these require adding other compounds. My suggestion is to try yeast strains that are less prone to producing hydrogen sulfide.
(1) Song Y, Gibney P, Cheng L, Liu S and Peck G (2020) Yeast Assimilable Nitrogen Concentrations Influence Yeast Gene Expression and Hydrogen Sulfide Production During Cider Fermentation. Front. Microbiol. 11:1264. doi: 10.3389/fmicb.2020.01264