If you have a door that has seen its better days, one way to fix it is to replace the entire unit. Make sure you can find a new door that matches the rest of the house before you start. Remove the old door by driving the hinge pins out of the hinges with a hammer and a long punch from the bottom side or just remove the screws and take the entire hinge off the frame. Then carefully remove the door casing (trim) by using a razor knife to score the paint and caulk around the trim and then use a flat pry bar to remove the trim.
Once the casing is removed you can use a reciprocating saw and cut the nails that hold the jam to the framing. Sometimes it is easier just to cut the jam legs about half way up and pry the jam out of the opening. Once you have the old unit removed it is time to set the new frame. Start by removing the door from the frame. Set the frame in the opening and level the top of the jam (the header.) It may be necessary to cut one of the jam legs at the bottom to make sure they are both on the floor and the header is level. Next make the hinge side jam leg plumb using shims and nail the leg into place. Reinstall the door and then shim the strike side of the jam into place making sure the reveal between the door and the jam is equal all the way around. Check to make sure the door opens freely without rubbing the jam. Then set all the nails, secure the jam, and then reinstall the casing. The casing aides in holding the jam in place when nailed properly.