Alger had been serving as a Unitarian minister in Brewster, Massachusetts for about a year and a half when a church committee charged him with pederasty. He denied nothing, said that he had been imprudent, and quit, vowing never to accept another ministerial post. Church officials were satisfied and no further action was taken. Alger relocated to New York City where he cultivated a humanitarian's interest in the city's many vagrant children. A prolific author, he published to great success in Student and Schoolmate, a children's monthly magazine, and, when its publisher asked him to develop a serial about street boys, he responded with a tale about bootblacks called Ragged Dick.
New York City's boot blacks at the time Alger wrote in Ragged Dick were boys usually between the ages of ten and sixteen "with any number of bad habits, and little or no principle". They gambled, smoked cigar butts retrieved from the gutter, patronized the Bowery theaters and concert halls, slept on the streets or in the shelters supported by the charitable, and were "more proficient in profanity than the Water Street roughs". Alger told the Ladies Home Journal in 1890, "I had conversations with many street boys while writing "Ragged Dick" ... and derived from many of them sketches of character and incidents".
Alger adapted the conventions of the moral, sentimental, and adventure literature of the period to fashion the formula he would employ in writing not only Ragged Dick but the dozens of boys' books that followed it. "Alger did not invent his formula out of whole cloth," Alan Trachtenberg explains, "[B]ut boiled down the conventions to make a more refined brew: a style accessible both to young and adult readers; clever dialogue and vivid descriptions; a cast of characters who presented a range of moral positions; a physical setting itself a part of the action."
Trachtenberg points out that Alger almost certainly consulted New York City guidebooks and incorporated their advice on crooks, cheats, and conmen into his manuscript, and explains that Alger's series books and characters bear similarities to the anecdotal nature of myths, legends, and folktales: "Stories of gods and of larger-than-life persons like Paul Bunyan have an anecdotal quality similar to the sequence of encounters, adventures, confrontations, and coincidences that comprise the narratives of Ragged Dick and Tattered Tom and their kin among Alger's legion of boy heroes."
Although Ragged Dick has been described as a "puerile fantasy of the assimilation of the so-called dangerous classes to the bourgeois social order", Sacvan Bercovitch believes Alger created "a relatively realistic hero" in Dick – one who smokes, swears, plays pranks, and spends what money he has with abandon, yet one who displays an emotional depth foreign to Alger's subsequent heroes who increasingly exhibited "the slow accretion of civilized instincts and habits, including proper speech, cleanliness, and courtesy" and who lacked Dick's "sense of humor, sadness, and critical intelligence".