The development of methods and algorithms to solve the N-body problem for classical, collisionless, non-relativistic particles has made it possible to follow the growth and evolution of cosmic dark matter structures over most of the universe&rsquo / s history. In the best-studied case&mdash / the cold dark matter or CDM model&mdash / the dark matter is assumed to consist of elementary particles that had negligible thermal velocities at early times. Progress over the past three decades has led to a nearly complete description of the assembly, structure, and spatial distribution of dark matter haloes, and their substructure in this model, over almost the entire mass range of astronomical objects. On scales of galaxies and above, predictions from this standard CDM model have been shown to provide a remarkably good match to a wide variety of astronomical data over a large range of epochs, from the temperature structure of the cosmic background radiation to the large-scale distribution of galaxies. The frontier in this field has shifted to the relatively unexplored subgalactic scales, the domain of the central regions of massive haloes, and that of low-mass haloes and subhaloes, where potentially fundamental questions remain. Answering them may require: (i) the effect of known but uncertain baryonic processes (involving gas and stars), and/or (ii) alternative models with new dark matter physics. Here we present a review of the field, focusing on our current understanding of dark matter structure from N-body simulations and on the challenges ahead.