The origins:

THE TIME MACHINE was H. G. Wells' first work of any literary importance. Within the brief years of 1895-98, Wells wrote: THE TIME MACHINE, THE ISLAND OF DR. MOREAU, AND THE WAR OF THE WORLDS. Not a bad record for a man of twenty-nine through thirty- two!

Wells got the germ of an idea about time travel from the students' debating society at Imperial College, London. He says,

      "I heard about and laid hold of the idea of a four 
      dimensional frame for a fresh apprehension of physical 
      phenomena, which afterwards led me to send a paper, 'The 
      Universe Rigid,' to THE FORTNIGHTLY REVIEW (a paper which 
      was rejected by Frank Harris as 'incomprehensible'), and 
      gave me a frame for my first scientific fantasia. THE 
      TIME MACHINE. . . .If there was a Universe rigid, and 
      hitherto uniform, the character of the consequent world 
      would depend entirely, I argued along strictly materialist
      lines, upon the velocity of this initial displacement.  The
      disturbance would spread outward with ever-increasing 
      complication.  But I discovered no way, and there was no 
      one to show me a way to get to get on from such elementary
      struggles with primary concepts, to a sound understanding 
      of contemporary experimental physics." 
       -- EXPERIMENT IN BIOGRAPHY, p. 172.

Wells and his soon-to-be second wife were
living in rented rooms in a semi-detached house at 23, Eardley Road. The
landlady disapproved of these arrangements and made loud comments to the
neighbors outside Wells' window. Some critics have found evidences of this
landlady in the character of the Morlocks. Wells recalls writing a turning
point in THE TIME MACHINE with the landlady's voice droning outside:
      "I still remember writing that part of the story in 
      which the Time Traveller returns to find his machine 
      removed and his retreat cut off.  I sat alone at the round
      table downstairs writing steadily in the luminous circle 
      cast by a shaded paraffin lamp.  Jane had gone to bed and 
      her mother had been ill in bed all day.  It was a very warm
      blue August night and the window was wide open.  The best 
      part of my mind fled through the story in a state of 
      concentration before the Morlocks but some outlying regions
      were recording other things.  Moths were   
      fluttering in ever and again and though I was unconscious 
      of them at the time, one must have flopped near me and left
      some trace in my marginal consciousness that became a short
      story I presently wrote, " A Moth Genus Novo." 
      And outside in the summer night a voice went on and on, a 
      feminine voice that rose and fell. . .I was aware of her 
      and heeded her not, and she lacked the courage to beard me
      in my parlour. "Would I never go to bed?  How could 
      she lock up with that window staring open?  Never had she 
      had such people in her house before, -- never. A nice lot 
      if everything was known about them. . .What she let her 
      rooms to was summer visitors who walked about all day and 
      went to bed at night.  And she hated meanness and there 
      were some who could be mean about sixpences.  People with 
      lodgings to let in Sevenoaks ought to know the sort of 
      people who might take them. . ."
          "It went on and on. I wrote on grimly to that accompaniment. I wrote her out
           and she made her last comment with the front door well and truly slammed. 
           I finished my chapter before I shut the window and turned down the lamp. And 
           somehow amidst the gathering disturbance of those days THE TIME MACHINE
           got itself finished." -- EXPERIMENT IN AUTOBIOGRAPHY, pp. 436-37.

The origin of THE TIME MACHINE came in a commission to Wells from the famous editor W. E. Henley, who had already published some tales by Wells in THE NATIONAL OBSERVER. Even the time traveller articles were not original. Wells derived them from a series called 'The Chronic Argonauts,' which he wrote for THE SCHOOLS JOURNAL.

Henley was about to start publishing a journal called THE NEW REVIEW, and he gave Wells the idea that he should re-work the time traveller material into a novel.

        New York: MacMillan, 1934.