Anyone else wonder about this in the various origins? Some of the reasons for his being there made sense and others... not so much.
Human Noble: Coming to Highever castle to test a single candidate while in the midst of fighting off a Darkspawn horde... Huh? The enemy marches but he's going to the other end of the country for one dude??
Human/Elf Mage: Coming to the tower to get more mages for the army. Ok, I'll buy that one... even though he only leaves with one?
City Elf: Roaming around the slums of the capital for no particular reason while the horde in the south grows ever larger... 0.o
Dalish Elf: Comes across you as he is hunting a rouge Darkspawn group... ok. Little weird, but ok.
Dwarven Commoner: Visiting an under ground city watching a "Proving"?? Huh? Horde... threatening the world and he's taking in the sights of dirt people? Are you kidding me??
Dwarven Noble: You meet him in the palace dining hall just before he and his men head out to investigate Darkspawn movements in the deep roads. Ok, sure. Why not? Put him there. Ancestors be with you.
I can't be the only one who thought about this at one time or another. It does make sense for some of the origins to have Duncan pop up, but others... WTF WAS HE DOING THERE?!?!
As other people have said, the Grey Wardens desperately needed new recruits, but people weren't exactly lining up thanks to the country's residual distrust of them and unwillingness to sacrifice their own people to the lifetime gig of being a Grey Warden. He has to do a delicate balancing act of getting more recruits to flesh out their piddling numbers, but ALSO not pick up too many to upset local Fereldens who might withdraw support at any time / jump at the chance to kick them out, AND pick up only those he thinks has a good chance of surviving the Joining.
Human Noble: The Couslands and their knights are Mary Sue badasses who have the entire country grovel over them just for existing, not to mention rich human nobles have the wealth, time, and nutrition to afford being well-trained fighters, so it makes sense that he would go to a socially accepted and supported (and funded) bunch of badasses.
Mage: As Duncan says, the Grey Wardens can use more mages. However, Gregor and the Chantry won't agree to giving up too many mages, and since the Chantry and Templars hold a lot of social and legal clout with the country, getting on their bad side by demanding too many could lead to people turning on the Grey Wardens. So he has to narrow it down to one or two. As others have said, Gregor's apprentice (you) has a phenomenal reputation that proceeds Duncan meeting you (it helps you passed your Harrowing with flying colors the night before he shows up, and everyone in the Circle is talking about it when he comes in), so since he was hoping to find one or two great recruits anyway, the most outstanding pupil is a natural first choice.
City Elf: I take offense to that. Duncan knew the City Elf's mother, remember? In his words, Adaia was an excellent rogue/warrior who would have made an excellent Grey Warden, but since there was no Blight at the time, he didn't press it. However, there is a Blight now. Since he's known for a long while that she passed her training onto you, it's heavily implied he came to the alienage specifically to see if you have your mother's spark. When you successfully save the women, he becomes convinced you are your mother's child after all, and thus an excellent recruit.
Dalish: As others have said, he's hunting unusual darkspawn activity. The darkspawn aren't ONLY showing unusual activity in Ostagar, though that is where they're gathering in greater numbers. The Grey Wardens have learned not to ignore unusual darkspawn activity since it usually points to either a Blight, or preparations for a Blight. Better sniff it out and nip it in the bud than just let it alone and cry "Woe is us!" after.
Dwarf: Are you serious? "Dirt people"? Did you sleep through the part where it says that the Dwarves have been successfully fighting and holding the darkspawn at bay for centuries? That the darkspawn have been driving at them again and again endlessly since they first appeared a thousand years ago, and only let up when they go to the surface for a Blight? That the dwarves have basically been dealing with an unending Blight for the last 900 years and still managed to hold their own? That's damned impressive and desirable for the Grey Wardens. Even Loghain, who doesn't think much of the Grey Wardens, comments that it was very sensible for Duncan to choose one of the Orzammar dwarves if he meets a Dwarf Warden.
As for each specific origin: The Proving in the Dwarf Commoner is a tournament filled with the best of the best of the seasoned darkspawn veterans, all fighting in single combat to root out who is the most skilled and powerful.That the Dwarf Commoner happens to have humble origins is incidental to Duncan. You, an untrained sellsword, manage to defeat all of Orzammar's most seasoned veterans in single combat.
As for the Dwarf Noble, again, the noble and warrior caste have been fighting and holding the darkspawn at bay for centuries. As a noble, it's been your job to fight darkspawn for a long while. Isn't the Dwarf Noble already considered a skilled, celebrated darkspawn fighter? If not, it still makes sense for Duncan to seek out the Orzammar noble and warrior caste to see who's the best fighter since, you know, they've been holding the darkspawn at bay for centuries.