Siltstone and shale are sedimentary rocks formed in ancient fresh and marine environments. They are "mudrocks" composed of mud slowly deposited from suspension in calm waters. Silica and calcium carbonate from dissolved minerals provide the cement necessary to eventually cement the mud into rock. As the marine environment dries during various epochs of climate change, the sedimentary rock is left behind.
TL;DR (Too Long; Didn't Read)
The short answer? Siltstones and shales form in environments where water is quite still and calm, as in lagoons, ponds or puddles, or offshore in lakes and oceans. The silt and clay particles are so small that they easily float if there are any currents. When the water is very still, the particles settle out to form the layers that eventually become siltstone or shale.
Siltstone and shale, two types of sedimentary rock called clastic rock, form from "clasts" -- that is, fragments of other rocks or minerals. When the rock fragments are buried and compacted, they form sedimentary layers. In the case of siltstone and shale, the clasts are tiny silt and clay particles. Over time, the buried sediment becomes cemented and forms sedimentary rock. Geologists can date sedimentary rocks relative to each other, because older rock is buried beneath younger rock.
Silt and Clay
Clastic sedimentary rocks are deposited in three ways: by water, glaciers and wind. Although siltstone and shale are similarly formed in water, identifying siltstone and shale requires distinguishing between silt and clay particles. Silt and clay are both tiny particles that have weathered away from rocks and minerals. Silt is intermediate in size between the larger grains of sand and the smaller clay particles. To be classified as silt, the particles must be smaller than .06 millimeters in diameter, (.002 inches) and larger than clay-size particles, which are smaller than .004 millimeters in diameter (.0002 inches). Clay, unlike silt, also refers to several types of minerals, including montmorillonite and kaolinite.
Shale Depositional Environment
Shale forms in an environment that consists of calm water: for example, water near the shores of large lakes or continental shelves at sea edges. The calmness of the water allows suspended particles like clay to eventually sink and settle in the bottom of the lake or sea. Silica and calcium carbonate from dissolved minerals and marine life, particularly from shells, also settle with the clay particles, and over time they form cement for the clay particles to "lithify" -- that is, become rock -- and form shale. When extensive organic material such as from plankton and plants becomes embedded with the shale, oil shale can form.
Siltstone Depositional Environment
Siltstone is deposited in a similar environment to shale, but it often occurs closer to the shoreline of an ancient delta, lake or sea, where calmer currents cause less suspension of particles. Siltstone commonly occurs adjacent to sandstone deposits -- that is, near beaches and delta edges where sand is deposited. Silt, hence siltstone, occurs in the water adjoining sandy beaches and deltas. Decreasing currents filter the sand from the smaller silt particles. The siltstone grades into shale in deeper water where the suspended clay particles are more abundantly deposited as the currents continue to lose energy. In either case, calm waters are needed for the suspension and sorting of silt and clay. Thus, sandstone, siltstone and shale are interrelated rocks that are distinguished by particle size.