I've got several thoughts, but none of them is complete. A general explanation is that when a few atoms form a structure with lowest energy, then when the interfacial energy is low, these independent small groups of particles tend to gather together and form periodic structure. But why are the interfacial energy always small? A theoretical explanation is that we believe that the atoms tends to preserve as many symmetries as possible. The competition of the two kind of interaction gives a characteristic length, therefore the continuous transverse symmetry should be broken, but the discrete transverse symmetry can be preserved. Then nature chooses to preserve it. But this explanation is too theoretical. How can we understand it in physical picture. Another way to understand the ques is that we consider how a crystal, say ice, is formed. It grows from a kernel, the competition of culom interaction and Pauli interaction determine the atoms form around the kernel. In every step, it seeks a energy-favor form, so it's easy to see that solid should have a special structure. But why the structure is periodic? Actually, it can form ice which is periodic, it can also form flake which is fractal. Then why in each case?
Try looking at it from a surface/volume ratio point of view. At relatively low temperatures, there is minimal energy available for dispersed conformations. The minimum entropy situation is closely packed nuclei. If the atoms are spherically symmetric and the same size, then the will form a cubic lattice. If you break any of these suppositions, the math gets more complex. At higher temperatures, defects build up. With multiple sizes, the unit repeating cell becomes more complex and less easy to pack. Similarly, atoms distorted through bonding are not spherical and won't pack as easily. More complexity requires more energy. Break all suppositions of these and you have a glass or liquid or gas.
Consider array of balls which each of them was connected to its neighbors by springs. It seems rational that equilibrium position of such a network would be periodic and if one of the balls be nearer to one side and farther from other side the total energy will be increased. The balls are atoms and the springs are inter atomic attractions between atoms. There is a quantum mechanical point too. When the atoms packed together the valence electron wave function expands all over the crystal and the Quantum kinetic energy decreases.