The thymus is one of the most important organs of the immune system. It is responsible for both the production of T cells and the prevention of their autoimmunity. It comprises two types of tissue: the cortex, where nascent T cells (thymocytes) are generated; and the medulla, embedded within the cortex, where autoreactive thymocytes are eliminated through negative selection. In mice, the medulla exhibits a complex, convoluted morphology, which has raised the question of whether its form impacts its function. Intriguingly, experiments also reveal a reverse dependency: the interactions between medullary stroma and thymocytes shape the medullary structure. However, understanding the underlying mechanisms of medulla morphogenesis emerging from these interactions remains elusive. Here, we present a conceptual theoretical model which shows that central, experimentally verified signaling pathways suffice to shape the convoluted medullary structure. The mathematical analysis of the model explains the observed effects of chemotaxis on thymocyte localization, as well as the reported morphological changes resulting from the modulation of thymocyte production. Our findings reveal that the established cross-talk between medulla growth and negative selection of thymocytes not only regulates medullary volume but also orchestrates the morphology of the thymus medulla. This mechanism of structure formation robustly organizes the medulla in a way that accelerates thymocyte negative selection by improving their chemotactic migration into the medulla. Thereby, we identify a feedback between the function of the thymus medulla and its form. Our theoretical study motivates further experimental analysis of the spatial distribution of thymic cell populations and predicts morphological changes under genetic perturbations.