Why do atoms arrange themselves in a regular fashion to form crystals? This questions has been hovering in my mind for a long time. Why would something which does not have life would to be in such a beautiful neighborhood, while the world is so much disordered. What causes them to be in that regular array and how they do choose which crystal structure is suitable for them?
For now, suppose somehow, for any reason, they want to be in that crystal form but then comes grains i.e. after a so short period of space their periodicity is broken! What decides all this?
From a simple Google search I came to know something about energy consideration i.e. system energy is minimized in this form. But this answer seems very blurry; it would be great if someone expands on this.
 A: There are many reasons why things form regular shapes in crystals
There are multiple levels of explanation here many of which are more chemistry than physics.
The first is to recognise that there are different forces making different compounds crystalline. Some crystals (eg quartz) are network solids with covalent bonds determining how the orientation of different atoms make up the structure; some are made up of ions (like common salt); some are made from discrete molecules with weaker interactions deciding the overall shape and orientation of the atoms and molecules in the structure (eg ice, menthol).
The simplest to explain are the covalent network solids. This includes a very wide range of mineral (though some have both ionic and covalent parts). In quartz the orientation and spacing of the atoms is essentially entirely determined by the covalent bonds. Each silicon has a tetrahedral arrangement around each silicon. Each Si is bonded to 4 oxygens and each oxygen is shared with two silicons. The Si-O bonds are covalent and the bond angles of those bonds impose the spatial orientation of the whole structure. Many other minerals have large covalent arrangements of silicon-oxygen structures (with different ratios of Si:O giving strings or planes of Si-O structures with a net charge filled out by oppositely charged ions. but, again, the macro structure is controlled by covalent bonds. The point of all these is that covalent bonds have direction and length and this determines the spatial orientation of the atoms.
Ionic solids are made up from discrete ions held together with undirectional electrostatic forces. Common salt is made from ions of sodium and chlorine, for example. The strong electrostatic attraction between the ions is what holds them together. But why regular structures? This is mostly determined by the packing efficiency of different ways of organising the ions. The lowest energy packing tends to determine the resulting structure. If, for example, you pack the sodium and chlorine ions in salt differently you get a higher energy solid which, if you give it enough time and freedom, will spontaneously rearrange to the more ordered structure (if you don't, you might well get a less ordered arrangement or very small individual crystals). The point being that the nice regular structure is the lowest energy one and, as long as there is enough energy in the system to explore alternative arrangements, this is what you will get even without any imposed plan.
Molecular solids are explained by a similar argument but the forces pulling the molecules together are weaker and more varied. Water crystals (ice) are controlled by hydrogen bonds which are weaker than covalent bonds (which is why water is normally a liquid) but which have direction. This directionality imposes a broadly hexagonal arrangement in crystals, if the cooling water has enough energy to test out enough arrangements to find the low energy optimal arrangement (which it sometimes doesn't giving a "glassier" structure where the overall pattern at the molecular level may be less obvious in the bulk. Other molecular structures are often held together by weaker dispersion (van der Waals) forces between molecules. But, again, the molecules tend to clump in specific ways that create the lowest energy arrangement of the bulk material and that often has a specific regularity (but not always as synthetic chemists or protein chemists often find out when the really, really want nice crystals to do x-ray structure analysis on).
The broad point of all of these factors is that there doesn't need to be a plan. Crystals form because their individual components have time to explore many arrangements as they crystallise and the lowest energy arrangement is the one they usually settle into, one component at a time. The structure of some crystals can be explained by strong directional forces holding them in particular orientations; other have weaker directional forces and some have weak dispersion forces where the lowest energy form may be less obvious. And those low energy structures are often regular. When the system doesn't have the energy or time to find that arrangement glasses form (of which, well, window glass is a good example).
A: The quantum  mechanical view, as without quantum mechanics there are no lattices.:
To first order all the organization we see in the microcosm that we model with quantum mechanics, is due to the electromagnetic interaction and the potentials involved.
The simplest solutions for an atom show the possible locations of the electrons in energy levels surrounding the nucleus . Molecules can form when the potentials of the two atoms allow for a solution, where there are various ways of sharing the electrons, thus generating molecular orbitals.  Depending on the atoms, there are "holes" in the space between orbitals,and this means that the electric fields about the molecules are not uniformly negative, but there are regions where the positive charge of the nuclei dominates, regions of positive and negative charge and the molecules  can be attracted and have new energy levels, given the temperature of the medium.
Depending on the temperature and the atom, lattices can form, conceptually similar to the way LEGO blocks are used, the positive with the negative regions locking in new lattice energy levels.
The energy binding the latices, and energy levesl, are much smaller than the energy binding the electrons to the nuclei, that is why low temperatures allow lattices (ice) and high temperatures lead to melt, depending on the  atoms involved.
You say:

but then comes grains i.e. after a so short period of space their periodicity is broken!

The small binding energy levels are at the bottom of this. For many crystals it is a small hit that sets up vibrations with enough energy to transfer enough energy  the molecules to be kicked  out of the energy level of the lattice.
A: When the universe try to increase entropy/disorderness, why do these things come closer in the first place?
This has to do with minimization of energy but in a subtle way. Here, you will also have to admit the existence of various forces in the universe. Say gravitational force, that likes to pull masses closer together, as close as possible until other forces/thermal agitations start to repel these masses. Repulsion will generally increase the Energy of the system, hence a compromise called equilibrium is reached. Now, the Stableness of these Equilibrium points decides the packing of things. Some equilibrium points are more stable(lower energy) than others.
This is were orderness of packing comes in. Ordered states are usually the most stable equilibrium points. Nevertheless, there does exist less stabler equilibrium point because of which not everything reaches the more stabler points. Hence, we commonly see small disorderness among a larger orderness.
A: To put it in simple terms:
In the case of metals, surrounding the nucleus of each atom is a cloud of electrons. While some of the electrons occupy clouds that are spherically symmetric, other clouds have lobes that point in certain directions. When settling into solid crystals, those atoms strive for the lowest energy state available to them, which involves accommodating any electron orbitals that are not spherically symmetric as they settle in together.
Although this effect is subtle, it makes certain orientations of nearest-neighbor atoms more likely than others, and certain specific crystal lattices are the result.
In the case of nonmetals, the binding that occurs between the atoms relies almost completely on those asymmetric electron clouds and the result will be a crystalline structure that can be exceptionally rigid (as in the case of diamond for example).
A: Well, you could take the anthropic view which would suggest that since we are alive to observe the universe then this universe must be the kind of universe from which order arises from disorder. Given, of course, that we are ordered beings.
Or you can take the physical view, which arises from empirical observations around us, that why a particular crystal takes the particular form it does will be to do with the fine structure of its atomic structure.
A: Existing answers offer some good physical insight but they are missing an essential ingredient I think, and that is to discuss entropy.
Many physical processes are the joint result of considerations of energy and entropy. For an isolated system (one that is not undergoing interactions with other systems), the system's internal energy stays constant and its entropy increases over time until it reaches some maximum value consistent with the other properties such as the fixed amount of energy.
In the case of a crystal what happens is that some process has acted to remove energy from the system, with the result that the atoms do not have enough energy to escape from their mutual attraction, so they have to gather close to one another. The puzzle now is why they don't just gather in some more haphazard way, rather than a regular lattice. To understand that you have to consider both the position and the motion of the atoms---their momentum.
Entropy, in physics, quantifies how many ways a given system can be rearranged internally without changing its overall properties, and this can be regarded as a measure of irregularity of lack of structure. Crystals have a regular arrangement of atoms, so this suggests the entropy is low, which is surprising. But in fact to maximise the entropy the system must maximise the range of available states of both position and momentum.
The states of lowest potential energy are the ones where the atoms form a regular lattice.
When the atoms go to those states, they make it possible for there to be more kinetic energy in their vibrations, and therefore a greater range of momentum states.
Overall this can result in more irregularity (i.e. entropy) in the complete state of position and momentum, compared to the case where the locations are less regular and the vibration (and consequently the range of momentum) is smaller.
Mostly when people discuss this they simply say that the system "seeks" or "goes to" the state of lowest energy. In fact the system cannot lower its energy overall, if it is an isolated system, so you should not accept such accounts. What people are really saying is that the system tends to lower its potential energy, but to understand why this is so we need to think about the kinetic energy too, and the way it impacts on the entropy, as I have discussed.
The regularity of the crystal reflects the fact that the atoms (or, more generally, the molecules) are all alike, so the minimum potential energy arrangement of one group is the same as for another group. So one can expect the least potential energy when the whole crystal is perfect. Crystals in general are not perfect (they have grains and boundaries) because the atoms originally gathered in multiple places at once, and these places just meet each other randomly. It takes a local input of energy to reorient any given grain. This
can happen but it takes a long time if one is just waiting for it to happen
by a random concentration of energy, so the crystal remains imperfect.
In the case of a system which is not isolated, it is the joint entropy of the system and its environment which is maximised. In this case, when a crystal forms it passes energy to its environment, with the result that whereas the crystal gets a state of lower entropy, the increase of entropy in the environment more than compensates. Notice that this principle extends to a vast array of phenomena. It is very common find a process where the entropy in one part of the world became smaller, because this led to an overall increase of entropy in the wider world. Such effects are at the root of most of chemistry and biology.
