That all depends on which motor. There are 2 main types: Geared and direct drive. And they both can last a long time.
The geared motors have an internal clutch and several gears. Most of the ones available now are fairly robust, but they can be damaged by agressive riding. their life span is limited by wear parts, but that might still be many many years, or even decades under normal riding conditions. I don't know of anyone who's worn one out yet, I don't think they have exsisted long enough for someone to find there upper end of milage yet.
Direct drive have only one moving part + the 2 bearings. They are very hard to kill even when ruthlessly abused and pushed way beyound there design limits. bearings can last many many decades as long as they are kept clean and greased, and spin for many hundreds of thousands of hours. And when the bearing fails, its effectivly a service part, so replace, and continue on.
The only other major reliability factor comes from manufacturer's defects. Lets face it, Hub motors aren't built like swiss watches. Defects do show up from time to time. Most show up early, and most problems can be corrected.
As for my personal experiance, My oldest and first motor I bought back in 2007. Its been used in a couple bikes now. The first bike's frame wore out. it got stress cracks and flexed too much after a hard abusive life. I put the motor into a stronger frame and has been running hard ever since. It's a little 500 watt motor pushed over 3000 watts reguraly. really, I have no idea how many miiles are on it. I know it crossed 10,000 a while ago, but I've not kept track. It runs as strong now as it did new.