There are many purposes of coral reefs in the ocean. Coral reefs protect the coastlines from damage from the water flow and tropical storms; provide habitats for marine organisms; they are a source of nitrogen and other essentials nutrients for marine food chains, help with fixing carbon and nitrogen and help recycle nutrients.
Citations
Queensland Museum, "05. Human Impact on the Reef," Queensland Museum, 2010-2012, http://www.qm.qld.gov.au/microsites/biodiscovery/05human-impact/importance-of-coral-reefs.html.