What would happen without coral reefs?

If coral reefs disappeared, essential food, shelter and spawning grounds for fish and other marine organisms would cease to exist, and biodiversity would greatly suffer as a consequence. Marine food-webs would be altered, and many economically important species would disappear.

Since it is also a shelter for fish, do all fish sleep or live in the corals?

Most fish rest. Some fish float in place, some wedge themselves into a secure spot in the mud or coral, and some even locate a suitable nest.