Limestone cliffs in Saudi Arabia
When the Earth was first forming, about six billion years ago, there weren't any sedimentary or metamorphic rocks, only igneous rocks like quartz that formed when melted silica, carbon, and other molecules cooled off and stuck together. But gradually some of these igneous rocks began 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. When you go to the beach, you see a lot of sand made from quartz, working its way into the ocean. 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, and 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 to squash 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.
A fossil of a dragonfly, from Germany, about 150 million years ago
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.