Fruits are a way for plants to spread their seeds. To attract animals and birds to the seeds and get them to spread the seeds, the plant makes the fruit sweet, soft, fragrant, and usually changes the color, to indicate that this fruit is ready to have its seeds scattered. Unripe fruits are not sweet, generally not fragrant, and remain a different color, so they are not picked before the seeds are ready.
During ripening, stored starches are converted to sugar. This makes the fruit sweet, and it also makes it softer. The pectin in the cell walls breaks down, further softening the fruit. The chlorophyll breaks down, allowing the yellows, reds, and oranges to show through. Anthocyanins are produced to get purples and reds, while also acting as sunscreens and antioxidants to keep the fruit tasting good.
The hormone that triggers ripening is a small molecule called ethylene. Commercial fruit growers sometimes pick the fruit (especially bananas) while it is still green and hard, so it can handle transportation without bruising. They then add ethylene gas to the containers of fruit, to start the ripening process. By the time the fruit is in the market, it is nearly ripe.