The following is largely taken as is from Google Docs "Fallout Shelter Efficiency Data"
I do not know the authours or contributors of this document in any way.
The in-game guide states "The further out they go, the better rewards they'll find, but the harder the encounters will become"
This infers that as the probability of loot being rare/legendary increasing with time.
A regular loot event occurs every 60 minutes for all dwellers exploring in the wastelands.
This is confirmed to have a chance to acquire rare and legendary gear. Only Legendary weapons have been gained this way, not armour.
Rare drops after 25 days in the wastes are confirmed to be 100%.
- Chance at Rare = Duration in Minutes / 36,000
- Chance at Legendary = Duration in Minutes / 360,000
- Chance at Legendary may be capped at one legendary per expedition.
Also, when your dweller reaches 60 hours (plus or minus 15 minutes), they will encounter the National Guard Depot. This will always happen. However, you do not always gain the legendary gear. It is suggested that this is based on a Perception test, but this is not confirmed.
If you are looking for Legendary gear, stay out there as long as possible, but consider coming back as soon as you have one.
If you are are okay with only 1 piece of Legendary equipment per expedition, stay out as long as possible and collect as much better-than-common gear as possible. And if you find that you can indeed gain more than 1 Legendary gear, then by all means share that information.