I’ve heard many versions of this story. I found this one HERE:
Nasrudin was caught in the act and sentenced to die. Hauled up before the king, he was asked by the Royal Presence: “Is there any reason at all why I shouldn’t have your head off right now?” To which he replied: “Oh, King, live forever! Know that I, the mullah Nasrudin, am the greatest teacher in your kingdom, and it would surely be a waste to kill such a great teacher. So skilled am I that I could even teach your favorite horse to sing, given a year to work on it.” The king was amused, and said: “Very well then, you move into the stable immediately, and if the horse isn’t singing a year from now, we’ll think of something interesting to do with you.”
As he was returning to his cell to pick up his spare rags, his cellmate remonstrated with him: “Now that was really stupid. You know you can’t teach that horse to sing, no matter how long you try.”
Nasrudin’s response: “Not at all. I have a year now that I didn’t have before. And a lot of things can happen in a year. The king might die. The horse might die. I might die.
“And, who knows? Maybe the horse will sing.”