An unexpected and fateful encounter unfolds in a surprisingly public area. King Saul enters a cave right off the main road, completely unaware that David and his men are hiding inside. The cave is located near sheepfolds, which are enclosures where flocks rest [מצודת ציון, ביאור שטיינזלץ]. Because it sits directly on a busy path in an area filled with shepherds, it appears to be a terrible place to hide. This explains why Saul feels entirely safe entering the cave alone. Not only is his army stationed close by [ביאור שטיינזלץ], but he also assumes David would never risk hiding in such a visible, heavily trafficked location. Yet, in a twist of irony, this is exactly why David and his men choose to take shelter there. They understand that Saul will never think to search for them in such an obvious place [מלבי״ם].
Saul goes into the cave to relieve himself. While there is a possibility that he went to urinate, the primary approach among commentators is that he went to have a bowel movement [רש״י, רלב״ג, רד״ק]. The manner in which he does so highlights his deep sense of modesty. He acts in the custom of dignified individuals who use their clothing to drape over their legs, much like a canopy or small tent, while relieving themselves. This ensures that their flesh remains completely hidden from view [מצודת ציון, רלב״ג, רד״ק].
At that exact moment, David and his men are positioned at the very back of the cave. Deep within its innermost recesses, they sit quietly, remaining completely hidden from the king [מצודת ציון, רד״ק, ביאור שטיינזלץ].