Although the existence of nematic order in iron-based superconductors is now a well-established experimental fact, its origin remains controversial. Nematic order breaks the discrete lattice rotational symmetry by making the x and y directions in the iron plane non-equivalent. This can happen because of a regular structural transition or as the result of an electronically driven instability-in particular, orbital order or spin-driven Ising-nematic order. The latter is a magnetic state that breaks rotational symmetry but preserves time-reversal symmetry. Symmetry dictates that the development of one of these orders immediately induces the other two, making the origin of nematicity a physics realization of the 'chicken and egg problem'. In this Review, we argue that the evidence strongly points to an electronic mechanism of nematicity, placing nematic order in the class of correlation-driven electronic instabilities, like superconductivity and density-wave transitions. We discuss different microscopic models for nematicity and link them to the properties of the magnetic and superconducting states, providing a unified perspective on the phase diagram of the iron pnictides.