It's rare to find a wooden fence gate that can last for five years without sagging or twisting. When the latch goes out of alignment, it won't close properly, and that can be a problem when you have kids or pets to keep in the yard. Assuming the post that holds it is still firmly planted in the ground, the problem is usually loose hinges or warped wood. In the best of circumstances, tightening the hinges restores the gate's alignment, but when you have to straighten warped wood, you need the pulling power of a cable and turnbuckle.
Tighten all the hinge screws with a screwdriver. Remove any screw that is stripped or loose and replace it with a longer screw of the same gauge. If any screw is loose because the wood has cracked, you need to repair the crack.
Support the outside corner of the gate with blocks, unscrew all the screws holding the hinge that is attached to the cracked wood and swing the hinge away. Mix enough two-part epoxy wood putty to fill the crack and trowel it in with a putty knife.
Wait for the putty to set, then swing the hinge back and drill a 1/4-inch pilot hole through each of the holes in the hinge. Drive a screw into each hole.
Reinforce the gate with a cable if the wood itself is twisted. If the gate already has a diagonal wooden brace, the cable should form an X with it. Make marks on the corners of the fence frame that produce this pattern.
Drill a 3/8-inch hole on each mark and screw in a 3/8-inch eyebolt. The eyebolts should sink at least an inch into the wood. Feed a cable through one eyebolt, stretch it to the other and feed it through that one, then bring the end back to the center to meet the other end of the cable.
Connect one end of the cable to a turnbuckle by feeding it through the turnbuckle eye, folding it over and joining it to the cable with a crimp ring. Crimp the ring with pliers. Connect the other end of the cable to the other side of the turnbuckle in the same way. Trim the ends of the cables with wire cutters.
Tighten the turnbuckle by turning the central nut with a wrench. This will draw the corners together and straighten the gate. If the gate goes out of alignment in the future, you can straighten it by tightening the turnbuckle more.