In general, large solar flares are more efficient at accelerating high-energy electrons than microflares. Nonetheless, sometimes microflares that accelerate electrons to high energies are observed. Their origin is unclear. We statistically characterized microflares with strikingly hard spectra in the hard X-ray (HXR) range, which means that they are efficient at accelerating high-energy electrons. We refer to these events as "hard microflares." We selected 39 hard microflares, based on their spectral hardness estimated from the Solar Orbiter/STIX HXR quicklook light curves in two energy bands. The statistical analysis is built on spectral and imaging information from STIX combined with extreme ultraviolet (EUV) and magnetic field maps from SDO/AIA and SDO/HMI. The key observational result is that all hard microflares in this dataset have one of the footpoint rooted directly within a sunspot (either in the umbra or the penumbra). This clearly indicates that the underlying magnetic flux densities are large. For the events with the classic two-footpoints morphology, the absolute value of the mean line-of-sight magnetic flux density (and vector magnetic field strength) at the footpoint rooted within the sunspot ranges from 600 to 1800 G (1500 to 2500 G), whereas the outer footpoint measures from 10 to 200 G (100 to 400 G), therefore about ten times weaker. In addition, approximately 78<!PCT!> of the hard microflares, which exhibited two HXR footpoints, have similar or even stronger HXR flux from the footpoint rooted within the sunspot. This contradicts the magnetic mirroring scenario. The median footpoint separation, measured through HXR observations, is approximately 24 Mm, which aligns with regular events of similar GOES classes. In addition, about 74<!PCT!> of the events could be approximated by a single-loop geometry, demonstrating that hard microflares typically have a relatively simple morphology. Out of these events, around 54<!PCT!> exhibit a relatively flat flare loop geometry. We conclude that all hard microflares are rooted in sunspots, which implies that the magnetic field strength plays a key role in efficiently accelerating high-energy electrons, with hard HXR spectra associated with strong fields. This key result will allow us to further constrain our understanding of the electron acceleration mechanisms in flares and space plasmas.