The Dead Marshes in the Lord of the Rings were most likely inspired by J.R.R. Tolkien’s involvement in WW1. Bomb craters would fill up with rain and dead soldiers from both sides could be seen floating inside the craters.
Once a part of the ancient battlefield of Dagorlad, the Dead Marshes lie north-west of the Morannon, the principal entrance to Mordor. Several battles were fought here, most notably the Battle of Dagorlad at the end of the Second Age when the Last Alliance met the forces of Mordor with many casualties on both sides amongst Elves, Men, and Orcs. Through the years, the marshland began to encroach upon parts of the battlefield, and engulfed the dead that lay there. The Marshes are also known as ‘The Mere of Dead Faces’; they are described in The Passage of the Marshes in The Two Towers as “dreary and wearisome. Cold, clammy winter still held sway in this forsaken country. The only green was the scum of livid weed on the dark greasy milky surfaces of the sullen waters. Dead grasses and rotting reeds loomed up in the mists like ragged shadows of long forgotten summers.” 
On their way to Mordor to destroy the One Ring in T.A. 3020, Frodo Baggins and Samwise Gamgee are led through the marshes by Gollum. The bodies seen resting in the pools of the Marshes are perhaps incorporeal, merely the images of those who have fallen – as Gollum says, “Only shapes to see, perhaps, not to touch.” Frodo is mesmerized by the candle-like lights that appear to float over the Marshes (called by Gollum “candles of corpses”); those who are hypnotised by these lights, and who therefore try to touch the bodies, are likely to drown in the waters and join the dead. In the book, Gollum reveals the dangers to Sam, who calls to the stiff and lifeless Frodo and breaks his trance before he can touch the waters.
In a 1960 letter Tolkien said that “the Dead Marshes and the approaches to the Morannon owe something to Northern France after the Battle of the Somme. They owe more to William Morris and his Huns and Romans, as in The House of the Wolfings or The Roots of the Mountains.