When the Earth was first forming, about six billion years ago, there weren’t any sedimentary or metamorphic rocks. The only rocks were igneous rocks like quartz. These formed when melted silica, carbon, and other molecules cooled off and stuck together. But gradually some of these igneous rocks started to break down into smaller rocks, and then into little grains of sand and clay.
When it rained, or the wind blew, these little grains washed away or blew away, and eventually they fell into rivers and oceans. If you go to the beach, you can see a lot of sand made from quartz, working its way into the ocean (or thrown up by the waves). When you dig a hole in the dirt to plant tomatoes, that dirt is also made of broken-down rocks that blew away or were washed away. So there’s more good dirt in river valleys than there is on top of hills.
By about 3.9 billion years ago (just a little less than four billion years ago), these loose bits of dirt and sand began to clump together again to make new rocks. These were the first sedimentary rocks. Most sedimentary rock forms in water, where the weight of the water presses down on the layers of sand and clay. The weight squashes them together into a new rock. Sometimes animals and plants get stuck in between the layers, and then fossils in their shape get molded into the new stone.
Because some kinds of grains, like sand, are bigger and heavier than other kinds, like clay, they sink faster when they fall into the lake or the ocean. That’s how you get different kinds of sedimentary rocks. Some kinds are mostly made near shore, and they have mostly sand in them, like sandstone. Other kinds are mostly made farther from shore, and they have mostly clay in them, like shale. The particles that get furthest from shore are the ones that make limestone. All of these rocks still form today, just the same way they formed billions of years ago.