Door hardware components that are used for holding the door to the door frame, and used to ensure the door latches properly include hinges, door knobs, latches, and strike plates. If when you close the door, the latch fails to seat within the strike plate, and there is a large gap between the door edge and door jamb (on the strike plate side), the use of shims installed behind the hinges is likely the preferred repair. If the door edge is close to the door jamb (on the strike plate side, and the latch does not fit into the strike plate opening, adjustment of the strike plate itself is likely the repair that will work the best.
If the door latch is not seating into the strike plate, the strike plate itself may need to be adjusted. In order to do this, you will need a sharp wood chisel in order to remove wood material from the door jamb. First you need to determine whether the strike plate needs to be adjusted up or down, and this can be accomplished by marking where the latch meets the strike plate. Once you figure out which direction the strike plate needs to be adjusted to, you can remove the strike plate, and use the chisel to remove wood from the jamb as needed.
Sometime the door jamb itself may be damaged. In that case, use of shims at the strike pate could resolve the issue, however in home cases the door jamb itself may require repair or replacement.
Check out the video below for a more detailed look at how to correct a misaligned door latch.