How ecological, developmental and genetic mechanisms interact in the genesis and subsequent diversification of morphological novelties is unknown for the vast majority of traits and organisms. Here we explore the ecological, developmental, and genetic underpinnings of a class of traits that is both novel and highly diverse: beetle horns. Specifically, we focus on the origin and diversification of a particular horn type, those protruding from the pronotum, in the genus Onthophagus, a particularly speciose and morphologically diverse genus of horned beetles. We begin by documenting immature development of nine Onthophagus species and show that all of these species express pronotal horns in a developmentally transient fashion in at least one or both sexes. Similar to species that retain their horns to adulthood, transient horns grow during late larval development and are clearly visible in pupae. However, unlike species that express horns as adults, transient horns are resorbed during pupal development. In a large number of species this mechanisms allows fully horned pupae to molt into entirely hornless adults. Consequently, far more Onthophagus species appear to possess the ability to develop pronotal horns than is indicated by their adult phenotypes. We use our data to expand a recent phylogeny of the genus Onthophagus to explore how the widespread existence of developmentally transient horns alters our understanding of the origin and dynamics of morphological innovation and diversification in this genus. We find that including transient horn development into the phylogeny dramatically reduces the number of independent origins required to explain extant diversity patters and suggest that pronotal horns may have originated only a few times, or possibly only once, during early Onthophagus evolution. We then propose a new and previously undescribed function for pronotal horns during immature development. We provide histological as well as experimental data that illustrate that pronotal horns are crucial for successful ecdysis of the larval head capsule during the larval-to-pupal molt, and that this molting function appears to be unique to the genus Onthophagus and absent in the other scarabaeine genera. We discuss how this additional function may help explain the existence and maintenance of developmentally transient horns, and how at least some horn types of adult beetles may have evolved as exaptations from pupal structures originally evolved to perform an unrelated function.