The ideas for Flowers for Algernon developed over 14 years and were inspired by events in Keyes's life, starting in 1945 with Keyes's conflict with his parents who were pushing him through a pre-medical education despite his desire to pursue a writing career. Keyes felt that his education was driving a wedge between him and his parents, and this led him to wonder what would happen if it were possible to increase a person's intelligence.
A pivotal moment occurred in 1957 while Keyes was teaching English to students with special needs; one of them asked him if it would be possible to be put into an ordinary class (mainstreamed) if he worked hard and became smart. Keyes also witnessed the dramatic change in another learning-disabled student who regressed after he was removed from regular lessons. Keyes said that "When he came back to school, he had lost it all. He could not read. He reverted to what he had been. It was a heart-breaker."
Characters in the book were based on people in Keyes's life. The character of Algernon was inspired by a university dissection class, and the name was inspired by the poet Algernon Charles Swinburne. Nemur and Strauss, the scientists who develop the intelligence-enhancing surgery in the story, were based on professors Keyes met while studying psychoanalysis in graduate school.
In 1958, Keyes was approached by Galaxy Science Fiction magazine to write a story, at which point the elements of Flowers for Algernon fell into place. When the story was submitted to Galaxy, however, editor Horace Gold suggested changing the ending so that Charlie retained his intelligence, married Alice Kinnian, and lived happily ever after. Keyes refused to make the change and sold the story to The Magazine of Fantasy & Science Fiction instead.
Keyes worked on the expanded novel between 1962 and 1965 and first tried to sell it to Doubleday, but they also wanted to change the ending. Again, Keyes refused and gave Doubleday back their advance. Five publishers rejected the story over the course of a year until it was published by Harcourt in 1966.