Limestone is a sedimentary rock, made up mostly of the mineral calcite, a form of calcium carbonate, CaCO3.

The calcium carbonate is originally produced by living organisms. Later, some of it goes into solution in sea water. Limestone rocks include mainly organic remains and precipitated carbonate.

Limestone is about 10% of the total volume of all sedimentary rocks.

Formation 
Limestones are mostly made of calcium carbonate. It is originally made by small photosynthetic protists like certain bacteria, coccolithophores, and algae. Then the carbonate gets used by various animals, like bivalves and the polyps which make coral reefs. They build their shells or framework out of CaCO3 crystals. 
"[Coccolithophores] were the first organisms to bring about a steady rain of calcium carbonate from the upper, illuminated zone of the ocean towards the deep sea".p144

Carbonates are rocks formed from these sources, plus any CaCO3 which is precipitated out of solution. Some carbonate dissolves in the water. It gets  precipitated when the physical condition of the water changes. For example, if the concentration of CaCO3 is high, then a temperature drop, or a pH (acidity) change, can cause precipitation.

Florida Bay 
Florida Bay, the shallow lagoon behind the Florida Keys, is a model for the conditions which produced limestones on the continental shelf. Of course, all the species were somewhat different then but, as an ecosystem, it is similar.

In Florida Bay there is a lot of a type of flowering plant called sea grass. There is also a lot of white, milky water full of calcium carbonate. This is mainly formed by Melobesia, a small red alga which lives on the sea grass.p151 Finally, the organisms produce huge amounts of slime, which is a polysaccharide. There is good reason to think the slime is produced by microorganisms to control the way their carbonate skeletons are formed.p139 As a side-effect the slime limits the amount of carbonate which goes into solution.p155

Florida Bay is a flat platform which has laid down a huge amount of carbonate rock. 
"You have to drill for more than 3000 feet before you reach a different rock type, and that is of Cretaceous age—some 70 million years ago".p158

Fossiliferous limestones 
Many limestones contain fossils, and some are made up almost entirely of skeletal material. Chalk is ~99% coccoliths; Solnhofen limestone is famous for its animal fossils; and there are many shelly limestones from different periods. Limestone is not found much before the Cambrian period, because shelled animals had not yet evolved.

Marble 

When limestone is heated to a high temperature, and squeezed at the base of a mountain, it recrystallizes into the metamorphic rock marble. Marbles are fairly dense, relatively easy to cut, or be shaped into blocks, and some forms are white in colour.

Uses 
Limestone is hard enough to resist weathering but usually soft enough to be worked (cut and carved) by stonemasons. It is used for building material. Limestone, particularly Portland limestone, became popular in the 19th and 20th centuries for building things such as churches, banks and houses. However, acid rain does slowly erode limestone.

Limestone is used to make glass and cement. It is also used to make iron in a blast furnace, to remove impurities from the iron ore.

Related pages 
Portland limestone

References

Carbonate rocks
Sedimentary rocks