Generally speaking, and up to a certain point for a given vehicle, the more air it takes into the combustion chamber, and the easier it is for the exhaust to leave the engine, the more hp and torque it will have. That's one of the main reasons that people modify the airbox, or replace the airbox with an aftermarket air intake system, to allow more air to reach the combustion chamber. Its also one of the main reasons why people install an exhaust system, from the header, or the catalytic converter, to the tailpipe, that has larger diameter pipes and more free flowing cats, resonators, and mufflers. How much hp and torque gain you get from either modification depends on the engine. For some engines its very little and not worth the expense. On others, it can be up to or more than a 5 hp and 5 ft. lbs. of torque gain from the air intake modification and the same gain from the exhaust system modification.
The tradeoff is that modifying either the incoming or outcoming air flow increases the noise, although some people want the increased noise and in fact the "noise" is a second main reason for such modifications. The noise factor is the reason that vehicles come from the factory with air intake and exhaust systems designed to minimize the noise. The trade off in minimizing noise is of course increased restriction in air inflow and outflow and a bit less hp and torque.
A third reason for such modifications is an alleged increase in mpg, which, personally, I have never seen adequately documented for any engine.