Pyrite can actually come in a range of crystalline morphologies, as seen below:

Image source: Modelling nanoscale $\ce{FeS2}$ formation in sulfur rich conditions (J. Mater. Chem. 2009, 19 (21), 3389), who state that the shape is dependent on the concentration of sulphur during its formation.
Modelling of cubic pyrite crystals, as in the picture in your question, are explained in the article Modeling the Shape of Ions in Pyrite-Type Crystals (Crystals 2014, 4 (3), 390–403.), modelling the following structure:

From the caption, the blue spheres represent $\ce{Fe}$ and the ellipsoids represent $\ce{S}$. The shapes of the constituent chemicals used in this diagram is based on their modelling, specifically one of the conclusions the author makes is that:
It turns out for $p$ valence shell ions that an isotropic ionic radius only occurs on cubic lattice sites. For all other site symmetries, however, two or three radial parameters will apply. Appropriate geometric shapes for $p$ valence shell ions are thus given by ellipsoids instead of spheres.
The $p$ valence ion in this case being sulphide. With this model in mind, the explanation provided in the caption for this diagram states:
The mesh inscribed into the sulfur ions now reveals the ellipsoidal compression along <111> directions. In this model, the number of contact points of $\ce{S}$ and $\ce{Fe}$ ions become four and six, respectively, and the ellipsoidal deformation is concluded to enable a stable packing.
The molecular shape does not necessarily mean that the pyrite crystal has a cubic shape, however if the conditions are right (pressure and temperature), and the composition is 'correct' - if the formation is in a iron rich environment (as per the first reference), then this molecular shape could express as a cubic crystal.