NSAID's work by slowing down the COX enzym, but how do does enzymes cause pain? because I've read that they're also needed for the body and do "good" things.
NSAIDs work by inhibiting COX-1 and/or COX-2. These are the key enzymes in prostaglandin biosynthesis. Prostaglandins act as messenger molecules in the process of inflammation and therefore can cause pain and other inflammatory symptoms. Source
COX-1 is normally present in different tissues of the human body and is for example important for maintaining the stomach lining. By contrast COX-2 mediated prostaglandin synthesis is only induced by injuries and inflammation. The analgesic effect of NSAIDs is therefore mainly based on the inhibition of COX-2.
There are to different classes of NSAIDs, non-selective (aspirin, naproxen, ibuprofen, ...) and COX-2 selective (celecoxib, parecoxib, ...-coxib). Due to the different roles of COX-1 and COX-2 these different drug classes have different adverse effects and differ in their analgesic effect depending on the dose. E.g. use of aspirin can lead to ulcers of the stomach or duodenum while COX-2 selective drugs do not cause gastric problems (but others).