There are two ways to answer this question- first, looking at what’s going on internally while the fruit is ripening and second looking at why these plants have evolved to do this at all, especially considering it’s seemingly a massive waste of the plant’s energy and resources to produce fruit of any color around its seeds.