This practice is often referred to as "clearing the engine" and serves two purposes. The temporary change in power has a positive effect on clearing potential fouling of spark plugs, which are susceptible to lead-fouling, carbon-fouling and oil-fouling.
The second effect is to provide feedback to the pilot on the status of the power plant. Should the engine not respond favorably to a clearing power change, then the pilot is immediately made aware of that, and can either take corrective measures, such as increasing the power and leaning the engine to burn off or dislodge deposits. Alternatively, if low to the ground on approach, the pilot is aware that there is a potential power plant issue and can plan accordingly should there be a need to alter his path.
This maneuver is best practice in a light piston powered aircraft during certain training maneuvers, such as simulated engine out procedures.
Furthermore, while notions of best practice vary, there is general consensus that extended low or idle power glides of one minute or longer should have an clearing power change. This power change may only last a second, and if so executed, has a negligible impact on the glide path of the aircraft.
Because aircraft such as helicopters, tend to run at high power settings in all phases of flight, this maneuver does not apply except in situations such as extended auto-rotation practices. Also, this maneuver has little benefit to turbine powered aircraft, and is not indicated for extended glide in aircraft so equipped.
So bottom line, clearing the engine has a preventative effect in that it provides a moment of power to alter power plant conditions which could lead to unreliable operation. Secondarily, if there is a degradation in the performance of the power plant, it provides the pilot notice of that, so that the pilot can situationally evaluate options and act accordingly.