It's been generally accepted that trilobites were marine animals, living only in the ocean. However, there are some specimens that might hint that some of them crawled out of the sea. The American Museum of Natural History (in New York) has a page about this. Here is a paper from Nature that also proposes that trilobites ventured beyond the ocean. Maybe way back in the Cambrian, trilobites became some of the first land animals.
These Olenellus romensis are from the Rome Formation. Similar examples may have crawled out of the sea and onto adjacent tidal flats.
Despite the long-standing, and well-established notion that trilobites were strictly-and-solely marine inhabitants, back in 2014, scientists investigating a series of Lower Cambrian deposits in the Appalachian Mountains of Tennessee discovered something they had not anticipated. Within outcrops of the 515 million-year-old Rome Formation, a team from the University of Saskatchewan found unmistakable fossil evidence which indicated that soon after beginning their lengthy crawl through Deep Time, some olenellid trilobites had already started journeying onto dry land – or at least onto sea-adjacent tidal flats.
The early Paleozoic rocks emerging from that expedition revealed two distinct types of trace fossils: cracks and tracks. The former were indicative of a shallow sea floor habitat that upon being exposed to direct sunlight, began to rapidly bake and crack.
The latter, however, were a decidedly different matter. These particular trilobite trackways, also known as Cruziana rugosa, presented telltale signs that more than half-a-billion years ago those highly adaptable animals were exploring the surrounding shoreline and taking advantage of the resource-filled tidal flats which bordered their aquatic home.