A door can go out of alignment because of settling of a home's foundation or swelling of the wood in the door or jamb. You can see the result when you run your finger along the gap at the top or side of the door. Instead of being straight, it's tapered, and that can make the door stick. Moreover, an out-of-alignment door may swing open or shut when ajar instead of remaining stationary, and the knob may not latch. You can correct all these defects with a few cardboard shims and without having to remove the door.
Examine the gap along the top of the door. If the outside end is narrower than the inside, you need to shim out the top hinge. The door probably has a tendency to swing shut when ajar. If the taper widens in the opposite direction and the door swings open, you need to shim out the bottom hinge.
Unscrew the hinge you need to shim with a Phillips screwdriver. Remove the center hinge as well, if there is one.
Place one side of one of the hinges on a piece of lightweight cardboard, such as you would find in a shoe box. Trace the outline of the hinge with a pencil and cut it out with a utility knife. Make six shims in this way.
Put two of the shims in the mortise on the jamb for the bottom hinge and screw the hinge back to the jamb. Put two more shims in the mortise in the door and screw the other half of the hinge to the door.
Shim out the middle hinge in the same way, but use half the number of shims. In this case, put one shim between the hinge and the jamb and one between the hinge and the door.
Check the gap and the operation of the latch. If there is still a taper, or the latch doesn't work, add more shims as needed. Remember to shim out the middle hinge half as far as the bottom one.