It is also there to control noise, improve fuel consumption and also the performance of the engine.
The exhausts is normally made up of three parts. The front end of the exhaust is usually known as the front pipe. This mainly funnels the exhaust gases from the engine cylinders into the exhaust. Today you would also see a catalyst after the front pipe, through which the gases pass. The catalyst is there to remove harmful gases.
Then you have the middle section which reduces noise. Finally there is the rear section of the exhausts, which also reduces noise and also emits the gases away from the vehicle.