Rotting is part of a life cycle. A living thing is born, it grows up, it gets old and it dies. All the while it is alive, it works to stop microbes from destroying it. And it is successful. But when it dies, there is nothing to stop microbes from using it as food. The microbes are bacteria and fungi. You can't see the bacteria, but you can see the fungi and we call it mould.
A living thing takes in moisture all of the time. Our cells are made of moisture, just as are the cells of plants. So when a living thing dies, no new moisture enters the cells. Gradually, therefore, the moisture evaporates from the cells. This is why a dead thing shrivels up, gets harder and gets smaller.
So rotting is due to microbes using the dead thing for food, but the shrivelling is a result of losing water. You can see all of that in the picture of an apple above.
The video below shows how rotting and decomposing play such a vital role in the woodlands of the Smokey Mountains, North Carolina.