As Zoneman correctly stated, the power called "Farsight" is basically how Yoda accomplished this.
Yoda told Luke when Luke was using the force to do a one handed handstand "Through the force, things you will see other places, the future, the past, old friends long gone". Right then it when Luke had his vision of Han and Leia on Cloud City.
But of course for Yoda to be able to literally pick out on person hundreds of light yearsa away and watch him at will is quick incredible and amazing and it really shows the incredible power and skill of Yoda.
Even more than that, Yoda was not only watching Luke from that distance, he was even able to read his mind and know his heart. This is even more revealing about how powerful Yoda really was. When Luke went back to Dagobah after rescuing Han from Jabba the Hutt, Yoda told him to beware of the dark side and seeking revenge. Yoda said "When rescue your friends you did, anger and revenge you had in your heart". Thus Yoda not only saw Luke take out Jabba the Hutt (which is why Yoda knew that Luke didn't require anymore training), but he was even able to read his mind and know what was in his heart too.
There is another thing that happened to Yoda on Dagobah when a Jedi historian actually came to Dagobah. He had tracked Yoda down through obscure archive records and sumized that Yoda might have fled to Dagobah. Yoda apologized to him and told him that he would have to erase his memory of ever finding him there, for the safety of the galaxy.
Yoda then seemed to increase in stature and power as he approached and the historian began to be terrified having no doubt that Yoda could accomplish exactly what he said he could do. But Yoda didn't want to hurt the man, so he made him promise to tell no one after explaining whhy it was SO critical that the galaxy think that Yoda was dead & never find him. The historian agreed to keep his secret and obviously did since the Emperor never did find out where Yoda was hding, though he knew that he was still alive.