At ordinary temperatures and at the subatomic level, chaos is the rule. At low enough temperatures, however, electrons are constrained, forming exotic phases that exhibit long-range order, or repeating patterns.
Materials that are absolutely perfect—in other words, materials that contain no defect of any kind—are usually not very interesting. Imagine being married to a saint: you would quickly be bored out of your mind! Defects and impurities can considerably change many properties of materials in ways that allow a wide range of applications.