A door latch takes a lot of abuse and occasionally needs some easy maintenance. There are times when a door latch will get so gummed up with dirt and the parts get worn that it is very difficult to get it to move in-and-out like it should. Instead, it will hit the door strike plate and just stop. The noise is loud and the door doesn’t latch.
If the tolerance between the door and the jamb is extremely close, the latch may hit on a flat part near the door (instead of the angled latch) and fail to engage. For this you can remove the strike plate, slightly mortise it, and reinstall it. For the most part though, a simple cleaning and lubricating will do the trick.
Remove the handles so that the latch mechanism is exposed. You can use a spray lubricant on the mechanism. Spray it on and wipe off any dust and grime from the mechanism. Move the latch in and out to work the parts. You can also push the latch in and spray into the surrounding area. You can use a rag to wipe off the parts, and when the rag comes out clean, give them a final shot of lubricant. Reassemble everything and the latch and knob should work much better.