From the Super Mario Wiki
These barrels resemble ordinary ones, except for a white question mark painted on their front. Donkey Kong can break open Question Barrels from a charge attack. They are most often required to progress through a level, as they either release a Peg Board or open a door. In some cases, such as Risky Reef, the released Peg Boards stray from the main level and lead to secret areas.
Many Question Barrels are featured in K. Kruizer III Engine, as breaking one usually reveals another, up until the last one reveals a Peg Board.
Question Barrels reappear in DK: Jungle Climber, with the same purpose.