What inspired poets of romantic era to write poems?
There were several elements that inspired the Romantic thinkers. One such idea was the Enlightenment period which preceded the Romantic one. The former emphasized scientific progress and a sense of devaluing emotions in the deliberation of judgment. The Romantics could not stand more opposed to this, as they stressed that individual emotions were the only way to establishing a sense of truth and understanding which was transcendent and unifying. Another motivation for the Romanticist thinkers was the idea of creating art as a reflection of this emotional state. Prior to the Romantics, art was structured in a manner that stressed form and technical proficiency over emotional products that sought to link the experiences of human beings in the process. The Romantics altered this with their belief that art can be a unifying social force which brings people together and allows a collective spirit of "the good, the true, and the beautiful" to emerge. Finally, an emphasis on nature and individuality helped to define and galvanize the Romantic movement, elements that were not stressed in periods before.
Wordsworth (et al) were also trying to escape from under the shadow of England's great poet Milton, who had dominated the poetic scene for the past half-century. Whereas Milton wrote epics of religious and political seriousness, the Romantic poets wanted poetry for the common man: a simpler, more natural voice, shorter in length, fewer conventions, inspired by nature, and reflecting the spirit of the times.
There are many other influences as well: nature; the French and American Revolutions; conceptions of art (the sublime, beautiful, picturesque); and women's rights. Also, prose (the novel) was giving poetry a run for its money in terms of popularity, so there was a shift in poetry toward prose-like conventions (intensely personal voice).
Since the Romantics, poetry has roughly been the same ever since!