I think it is made very clear in that scene that he was testing Luke. As SilverWook pointed out, as soon as Luke lost his patience, Yoda straightened up and announces that he is unteachable.
If Luke had known the silly little green muppet in the swamp was the great Jedi master Yoda he had been searching for all along, then he would have treated him very differently. By pretending to be a crazy lowlife, Yoda was able to learn a lot more about Luke's true character.