This June 2017 video from the USA says about itself:
Trilobites are famous not just because they were so beautifully functional, or because they happened to preserve so well. They’re known the world over because they were everywhere!
From the CNRS in France:
Arthropods formed orderly lines 480 million years ago
October 17, 2019
Researchers studied fossilized Moroccan Ampyx trilobites, which lived 480 million years ago and showed that the trilobites had probably been buried in their positions — all oriented in the same direction. Scientists deduced that these Ampyx processions may illustrate a kind of collective behavior adopted in response to cyclic environmental disturbances.
Though our understanding of the anatomy of the earliest animals is growing ever more precise, we know next to nothing about their behaviour. Did group behaviour arise recently or is it primeval? To answer this question, researchers from the CNRS, the University of Poitiers, UBO, Claude Bernard Lyon 1 University*, Cadi Ayyad University (Marrakech, Morocco), and the University of Lausanne (Switzerland) studied fossilized Moroccan Ampyx trilobites, which lived 480 million years ago. They showed that the trilobites had probably been buried in their positions — all oriented in the same direction, in orderly lines, maintaining close contact with each other through their long spines — during storms.
By comparing this observation with the behaviour of living animals such as North American spiny lobsters, the scientists deduced that these Ampyx processions may illustrate a similar kind of collective behaviour — adopted in response to cyclic environmental disturbances like storms or to chemical signals associated with reproduction.
This example would seem to suggest that group behaviour is of ancient origin and, from an early date, likely conferred an evolutionary advantage on the first animals, allowing them to survive environmental stress and improve their reproductive chances.
*- From the Laboratoire de Géologie de Lyon: Terre, Planètes, Environnement (CNRS / ENS de Lyon / Université Claude Bernard Lyon 1), the Laboratoire Géosciences Océan (CNRS / Université Bretagne Occidentale / Université Bretagne Sud), and the Institute of Chemistry of Materials and Media of Poitiers (IC2MP (CNRS / Université de Poitiers).