Grid cells in the entorhinal cortex fire when animals that are exploring a certain region of space occupy the vertices of a triangular grid that spans the environment. Different neurons feature triangular grids that differ in their properties of periodicity, orientation, and ellipticity. Taken together, these grids allow the animal to maintain an internal, mental representation of physical space. Experiments show that grid cells are modular, i.e., there are groups of neurons which have grids with similar periodicity, orientation, and ellipticity. We use statistical physics methods to derive a relation between variability of the properties of the grids within a module and the range of space that can be covered completely (i.e., without gaps) by the grid system with high probability. Larger variability shrinks the range of representation, providing a functional rationale for the experimentally observed comodularity of grid cell periodicity, orientation, and ellipticity. We obtain a scaling relation between the number of neurons and the period of a module, given the variability and coverage range. Specifically, we predict how many more neurons are required at smaller grid scales than at larger ones.