From the Super Mario Wiki
A Pepper is a type of spicy fruit that can either be green, red, or blue. They are the most hated food of the Yoshis. However, Black Yoshis and White Yoshis seem to like them in Yoshi's Story. If a regular Yoshi eats one, they will lose one petal from their Smile Meter.
Red and Green Peppers appeared in Mario & Luigi: Superstar Saga, and both of these plus a new Blue Pepper appear in Mario & Luigi: Partners in Time. In the Mario & Luigi series, they serve as stat boosters; Green Peppers raise defense and reduce weight, Red Peppers raise attack and weight, and Blue Peppers raise speed. In Mario & Luigi: Superstar Saga, they only affected one character, but in Mario & Luigi: Partners in Time, they affected all characters currently fighting. Also in the latter game, the added gravity changes were removed.
Peppers also appeared with the other fruit in Super Mario Sunshine at Delfino Plaza. If a Yoshi eats one, it will turn purple, but a Yoshi will never require one to hatch out of its egg. It is also used to defeat King Boo at the casino of Hotel Delfino. By throwing a pepper at his tongue, King Boo will be stunned, allowing Mario to damage him with another fruit.
A different type of pepper called the Dash Pepper appears in the game Super Mario Galaxy 2 which when eaten, allows Yoshi to run at an extraordinary speed. Peppers also made appearances in The Super Mario Bros. Super Show!, but only in one episode.