Rikaine Delmarre, a prominent "fetologist" (fetal scientist, responsible for the operation of the planetary birthing center reminiscent of those described in Aldous Huxley's Brave New World) of Solaria (a planet politically hostile to Earth), is murdered. Elijah Baley is called in to investigate, at the request of the Solarian government. He is again partnered with R. Daneel Olivaw. Before departing Earth, he is asked by Earth's government to assess the Solarian society for weaknesses.
The book focuses on the unusual traditions and culture of Solarian society. The planet has a rigidly controlled population of twenty-thousand, and robots outnumber humans ten-thousand to one. People are strictly taught from birth to despise personal contact. They live on huge estates, either alone or with their spouse only. Communication is done via holographic telepresence (viewing, as opposed to seeing).
Earth also appears to have evolved an unusual society, in which people spend their entire lives in confined (or "cosy") underground interlinked cities never venturing outside. Indeed, they become utterly panicked and terrified when exposed to the open air and the naked sun.
Ultimately, we find out that neighbor and fellow robotocist Jothan Leebig was working on a way of subverting the robots' inability to kill humans. This was achieved by understanding a missing word in the Three Laws of Robotics; "knowingly". He used this knowledge to cause the death of Rikaine at the hands of his wife Gladia, because Rikaine was opposed to his plans. Later on, he also manages to poison the "Police investigator" (until this murder, there had been no need for police on Solaria) using a pair of robots.
The key to this technique is that a robot cannot knowingly kill or knowingly allow a human to come to harm. But if the robot does not know that their actions will cause harm, then they will not be stopped by the Laws.
The future implication of this was pointed out by Elijah, that it can be extended to the point at which robots could be used to fight wars. (In the Asimov universe, this would be unthinkable, given the Three Laws.)
Leebig kills himself before he can be taken into custody, due to a very Solarian fear of human contact. The irony is that the "human" he was afraid of was Daneel Olivaw, a robot.
Despite knowledge of her guilt, Baley never discloses Gladia's role in the murder -- in part because he feels sorry for her and the belief that the fault of her breakdown was under the pressure of the Solarian way of life. He manages to have her sent to the Spacer capital planet of Aurora, where she can further her growth as a human being, something she could never do on Solaria.
After investigating the murder to a satisfactory conclusion, Baley returns to Earth a hero. The information he brings back is invaluable to the government, which was predicting the downfall of Spacer societies; the similarities between the nature of Solarian society and Earth society in their closed natures suggests a fundamental flaw in the Terran society.
A more thorough description of the after-effects can be found in the sequel to the Naked Sun, The Robots of Dawn. We also discover the remote end-point of Solaria's odd development in Foundation and Earth.
The Foundation series and the Spacer/Robot series seem originally to have been separate, though with some overlap of ideas. If the Galactic Empire is the far future, where have the robots gone? In Foundation's Edge Asimov begins to supply the answer, expanded in the other sequels and prequels.