*Peristalsis*, i.e., a motion pattern arising from the propagation of muscle contraction and expansion waves along the body, is a common locomotion strategy for limbless animals. Mimicking peristalsis in bio-inspired robots has attracted considerable attention in the literature. It has recently been observed that maximal velocity in a metameric earthworm-like robot is achieved by actuating the segments using a “phase coordination” principle. This paper shows that, in fact, peristalsis (which requires not only phase coordination, but also that all segments oscillate at same frequency and amplitude) emerges from optimization principles. More precisely, basing our analysis on the assumption of small deformations, we show that peristaltic waves provide the optimal actuation solution in the ideal case of a periodic infinite system, and that this is approximately true, modulo edge effects, for the real, finite length system. Therefore, this paper confirms the effectiveness of mimicking peristalsis in bio-inspired robots, at least in the small-deformation regime. Further research will be required to test the effectiveness of this strategy if large deformations are allowed.