Why does a yellow pepper taste sweeter than a green pepper?

There are many different types of peppers or chiles, but I assume this question is asking about bell peppers. A green bell pepper (which we often just refer to as a green pepper) is actually a fruit that is unripe. These peppers change colors as they ripen, going from yellow to orange and to red. They are sold in all these stages of ripening, causing us to refer to them as green, yellow, and red peppers as if they are different peppers.

As the bell pepper ripens, like many other fruits, its sugars start to develop. This is when some of the starches in the pepper are converted to simple sugars. Now, a bell pepper does not have as many sugars as, for instance, an apple, but it does have some. The riper the pepper, the sweeter it becomes. So, a yellow pepper is a bit sweeter than a green pepper, and a red pepper is sweeter than a yellow pepper.