The body uses inflammation for many healing actions. If you sprain a muscle, the body uses inflammation to generate swelling to immobilize the area against future damaging motion or use. Pain helps here too. This article has a very simple description of the processes involved. This swelling also provides an avenue for the healing nutrients to enter the scene and begin working, plus the swelling also stops bacteria from building up to amounts that could create infections. A warming of the area helps accomplish this feat.
Another method for the body to use inflammation is when it attempts to stop allergens or microbes from taking up residency in lung tissues.
There is a fine line to letting nature work healing but not going too far to add new damage to surrounding tissues, or generate long term damage or defects. Cold packs and warm heating pads are often used to not let swelling get to destructive. The key is to not limit healing.
Check out this report form Scripps Medical on ways to control inflammation.