Kirk and Spock beam down to the Elba II penal colony to deliver a new medicine that may cure the insane patients who are imprisoned there. Unfortunately, the megalomaniacal Garth (Steve Ihnat), one of the insane who was once a starship captain, has other plans and takes them prisoner. Garth subsequently uses his ability to change his physical form and masquerade as Kirk, planning to take Kirk's place as the Enterprise captain.
If you accept the magical plot concept of a human who has acquired the ability to shapeshift (complete with the proper clothes, etc.), you might find this episode somewhat entertaining. The Dual Kirk Plot is a cliche, but Garth nevertheless makes a good villain, torturing the colony administrator and launching into fury after his plan is halted via Kirk's "chess game" security.
Some of this is hopelessly corny and overplayed, especially Shatner's take on the Garth-as-Kirk tantrum. But I did at times enjoy Ihnat's character, as he pronounces himself "Lord of the Universe" and, in one particularly cruel scene, blows up Marta (Yvonne Craig), his own partner in crime. But, insane or not, Garth gets off too easy. It all bears very little scrutiny, but the lively glib entertainment level keeps the show afloat.