As is often the case, the phonograph was created as a result of working on improvements to two other devices—the telegraph and the telephone. Edison wanted a way to record messages and figured out a way to record sound on tinfoil-coated cylinders. In 1877, he created a machine with two needles: one for recording and one for playback. When Edison spoke into the mouthpiece, the sound vibrations of his voice would be indented onto the cylinder by the recording needle. When the playback needle was placed in the same track, the sound could be heard through a cone similar to the mouthpiece.
On the 12th of August in 1877 Edison recited "Mary had a little lamb" into the mouthpiece of the phonograph and was taken aback when he heard the machine play the words back to him. Like most inventors he was accustomed to finding several things that don’t work long before he found the one that did. After a few refinements, and a shift to wax cylinders instead of the fragile tinfoil, in 1878 Edison established the Edison Speaking Phonograph Company to sell the new machine.
Edison suggested other uses for the phonograph, such as: letter writing and dictation, phonographic books for blind people, a family record (recording family members in their own voices), music boxes and toys, clocks that announce the time, and a connection with the telephone so communications could be recorded. All of these uses and more are still quite common today.
Those original tinfoil recordings did not survive, the medium was just too fragile; however, at an event in 1927, celebrating the anniversary of the invention, Edison recreated the historic moment. An mp3 of that recording can be found at the Internet Archive.
Photo credit: "Edison and phonograph edit1" by Levin C. Handy Licensed under Public domain via Wikimedia Commons (link)