When someone gets "a kick out of it", what they're saying is they find something funny. A kick is a fast swing of the leg, meant to hit something. A donkey is a hoofed mammal that can balance on two legs and still accurately kick out with the back or front feet. This joke is playing on the phrase "get a kick out of it" and its different meanings. 
He bought a donkey because he thought he might get a kick out of it .