It is canonically undefined
In published 5e lore, the only mention of a warforged soul is in the introduction to the race:
“Pierce was built by design, while you were built by accident,” Lakashtai said. “The soul is what matters, not the shape of the vessel.”
“What makes you think he has a soul?” Gerrion said.
“What makes you think you do?”
— Keith Baker, The Shattered Land (Wayfinder's Guide to Eberron 69)
The excerpt appears to be leaning into the fact that it is not clear if warforged have souls. Nowhere else is the question brought up much less answered.
In the 2015 version of the Races of Eberron 5e Unearthed Arcana it came out and said this explicitly:
Although they are constructs, they have much in common with living creatures, including emotions and social bonds, and perhaps even souls. (3)
Though it is worth noting that this wording did not make it into the final published version.
In 3rd edition lore, the question was explicitly debated in-universe and came to no conclusion:
In the end, the Question of Souls, as that portion of the negotiations came to be known, was left unanswered. Warforged were freed because they could exhibit independent thought and free will. Today many people continue to think of warforged as creatures without souls, and citizens of Thrane often refer to warforged as “the soulless. (Races of Eberron 16)
And explicitly mentioned as an undefined point about the race:
When warforged are used, DMs should be mindful of potential controversies regarding the warforged: Do they have souls? (Races of Eberron 8)
It seems that through the time this race has existed, this ambiguity has purposefully been emphasized and left as part of the race.
Mechanically, they effectively do
The only thing that is clear is that warforged are living and are affected as if they were any other living thing by spells and other effects:
While they’re formed from stone and steel, warforged are living humanoids. Resting, healing magic, and the Medicine skill all provide the same benefits to warforged that they do to other humanoids. (Wayfinder's Guide to Eberron 69)
Mechanically this actually means that warforged should be affected by healing magic including resurrection spells that would require a soul. Thus, mechanically, the question doesn't really matter.
No lore reason is given for this, and in fact, the ability to be resurrected is canonically one of the supporting points for why they might have a soul though it also has a counter:
Breland argued that because warforged can be raised from the dead, they must have souls. Of course, House Cannith and Thrane countered that no warforged brought back from death told tales of any kind of afterlife. (Races of Eberron 16)
But, as lore leaves the answer ambiguous, your DM can decide the specifics of the flavor of why things work like they do.