In fact there is no reason to think they never existed and are not just Homo sapiens.
Scientific explanations of dwarves, giants and elves
In fact there are (pseudo science) theories which assume dwarves were just different hominid species (like Homo floresiensis) living till several hundred years ago. But more reliable theories describe such legends (and archeological findings) just as individual differences between specimens of homo sapiens which in the past could be bigger between various nations as humans were more isolated by geography (no planes, no trains, mountains are nearly untraversable) resulting in different groups describing the others as dwarves/giants respectively. Imagination and psychedelics could develop the idea further (as just individual differences could not justify legends about pixie, krasnoludek etc.).
On the other hand elves are thought to be folklore description of Williams syndrome (like werewolf is a folklore understanding of humans suffering rabies). It is not the only source of the idea (imagination could play a big role too) but if we want to find scientific explanation it is most feasible.
If you move back in time (like you assumed) to have other species of hominids still living around you do not need to introduce new ones as there were ones resembling what you are looking for (especially already mentioned hobbit-like Homo floresiensis).
As for me features assigned to dwarves, elves or giants are not enough distinctive to justify living in different habitats than Homo sapiens. Unless you count either habitats assigned to them by mythology or fantasy (mainly Tolkien as most of his successors inherit their races unchanged).
Germanic dwarves are believed to live in mountains (either in forests or in mines), but similar beings from other cultures could life in other places, like slavonic Krasnoludek which belongs to human houses (and are a kind of helpful spirits) or forests.
Elves are traditionally assigned to forests and believed to be great poets (which further justifies theory that they were just Williams syndrome sufferers rejected by their society) what Tolkien and other fantasy authors continues.
Giants appear in various mythologies and are could be just some feature assigned to powerful warriors (especially unfamiliar enemies), which gives no particular clues about their origin (unless we research factual data about humans of different ancient nations).
If you are writing a novel I would rather stick to existing stereotypical habitats of fantasy beings (if you want something new take races from mythology and not Tolkien, especially non-germanic, and non-nordic ones, as they are already overexploited).
If you want some scientific evidence just read about real hominids.