Stardate 42502.7 : the USS Enterprise is passing through a cluster of worlds - the Coalition of Madena, and detects a small cargo ship. Lieutenant Worf reports that the ship has an empty hold and a single occupant aboard. Data notes that the guidance system is inoperative, and the pilot is controlling the ship manually. Captain Picard hails the ship; a beaten-looking craft appears on the monitor, replaced by the face of a ruggedly handsome man. Counselor Troi opines that he's a harmless rogue. Picard asks if they could be of service.
Okona beams aboard with the fried component and soon starts flirting with the female crew. Data escorts Okona to his quarters who tries to engage in small talk and make jokes - Data replies that he is an android. Okona gives up. Data later attempts to learn about humor on the holodeck, but his efforts fall flat.
Worf picks up a small vessel trying to overtake them, locking lasers. Picard states that even the navigational shields could deflect lasers, but Riker remarks that regulations do call for Yellow Alert. Picard orders a reduction in speed and to drop main shields as well. When asked why, Picard responds with irony, "In case we decide to surrender to them." The craft hails the Enterprise - Debin of the planet Atlec. Picard asks his reason for their aggressive approach. Debin claims that they are towing the ship of a known criminal, Thadiun Okona. Picard says Okona was in need of repair and they rendered assistance and asks what the crimes were; Debin states it is none of his concern.
A second ship approaches, similar to Debin's but with different hull markings. A message comes in - Secretary Kushell of the planet Straleb, who demands Okona be handed over to him; Picard indicates that Debin has made the same demand. Kushell states his matter takes precedence. Picard tells the men to stand by and orders Worf to fetch Okona, who turns out to be dallying with a female member of the crew. He is taken to the bridge. Okona thinks he is in trouble for "socializing", but Picard says he's talking about Debin and Kushell, saying they are prepared to attack the Enterprise if he does not hand him over. Okona assures Picard he's no criminal, he's a gentleman and follows a code of conduct, and can offer no explanation for the demands.
Picard contacts Okona's accusers and asks them to beam over to the Enterprise to explain. Debin shows his young daughter Yanar (who is clearly pregnant) and claims Okona is the father. Kushell meanwhile claims that Okona has stolen the Jewel of Thesia. Debin argues that his grievance takes priority. Okona walks in, whereupon Kushell shouts "You took advantage of my son Benzan and used his friendship to plunder our treasures!"
Okona maintains innocence of the crimes. Picard can't decide to which man to hand him over - if he lets them decide, they'll fight over it. Okona offers another solution; let him go. He tells Picard to beam him to his ship and he'll take his chances on his own. Picard considers this reluctantly. Okona eventually decides to deal with the situation himself. He stands before the angry men and maintains that he is no thief but he didn't plan on being a "father" either. To rectify Yanar's case, he offers to marry her. Kushell agrees but Yanar says that as the victim she should decide. She accepts Okona's hand in marriage, but Benzan turns to his father and says the jewel wasn't stolen, that he has taken it, and rightfully since he is the family heir. He adds that he gave the jewel to Okona to present to Yanar as a marriage vow. The child is his, not Okona's. Okona admits that he delivered messages between the couple for months, and even smuggled them into each other's homelands. The couple hoped their marriage would solve the political disputes between their fathers.
Kushell tells Okona that he's dropping the charges and that Benzan must present the jewel to his wife to be. Benzan agrees to it, if Yanar agrees; she is hesitant, angry that Benzan tried to frame Okona, but finally agrees. Benzan says they'll find a planet to live on, but Kushell says they will live on Straleb. Debin shouts "Nonsense! They should live on Atlec", and they continue to bicker. Picard orders them to be returned to their ships.
Data returns to the holodeck with Guinan for her to see what he has learned about humor. Data takes the stage before a simulated crowd. In a Rodney Dangerfield-style, Data begins; "Good evening ladies and germs." The crowd roars with laughter, catching Data off guard. He continues, the growing laughter building his confidence, but he ultimately comes to realize the crowd was programmed to laugh at anything and everything he does, even pointless gestures, so he ends the program and returns to the bridge as Okona is leaving. Picard releases the tractor beam, Okona bids farewell and Wesley turns to Data and says "Say goodbye, Data". Data replies "Goodbye, Data," causing everyone to laugh. Data is surprised by their reaction until running a self query about the joke, realizing that it was an old comedy bit from Burns and Allen. He tries telling a few more (bad) jokes, which the others pointedly ignore before Picard orders the ship to leave.