We theoretically assess two mechanisms thought to be responsible for the enhanced performance observed in plasma discharges of the Wendelstein 7-X stellarator experiment fueled by pellet injection. The effects of the ambipolar radial electric field and the electron density peaking on the turbulent ion heat transport are separately evaluated using large-scale gyrokinetic simulations. The essential role of the stellarator magnetic geometry is demonstrated, by comparison with a tokamak.