When the landing party exhibits strange behavior, Kirk sends another party down to investigate. They find the culture on Beta III is quiescent, with no creative tendencies. The entire culture is controlled by a group of 'lawgivers' known as "The Body" which is, in turn, controlled by the omniscient Landru. The inhabitants change from normal, peaceful people to a violent mob at the coming of the Red Hour. This 'Festival' is the society's only outlet for the tyrannical hold that Landru has over them at all other times.
Meanwhile, the U.S.S. Enterprise is being pulled from its orbit, its crew to be absorbed into the Body. This, they discover, is what happened to the U.S.S. Archon, so many years before.
Archon survivors have formed an underground of sorts to fight the Body, and they help Kirk and Spock reach Landru. Landru turns out to be an incredibly complex computer built by Landru, a scientist who lived 6,000 years before, who wanted to guide his people into a peaceful, civilized progress.
Landru had affected the computer with his scientific thoughts and memories, but not his wisdom. For centuries the computer, 'Landru,' has been interpreting his suggestions to the point that no one is allowed independent thought. Kirk tells the computer that instead of helping to nurture the culture of Beta III, it has harmed it. Landru destroys itself, leaving the Betans to work toward the sort of culture Landru had wanted so many centuries before. With the promise of Federation help on the way, Kirk and his crew beam back to the U.S.S. Enterprise.