When a whale dies, its body sinks to the ocean floor and becomes food for various animals and organisms. Typically, it takes decades for a whale carcass to be completely consumed in the ocean.
Larger animals such as sleeper sharks and hagfish eat the meat off of whale carcasses. Once the larger animals have picked away most the meat, smaller organisms such as marine worms colonize the whale carcass and eat any remaining meat. After all the remaining fat and meat is gone, bacteria consume the fat left in whale bones. Once the whale carcass is no longer a food source, the remaining whale bones are used by different ocean animals as tools to get higher in the water current.