For a really healthy and full term baby the baby should remain hopefully in the mothers womb for a period of 37 weeks.
If the baby is born before 37 weeks then the baby could have trouble breathing on their own and may not survive but there have been many babies born at 35 and 36 weeks who have survived but needed to be in the NICU for awhile before they became healthy enough to go home.
The longer the baby stays in mothers womb the better but the baby should be born before 40 weeks otherwise complications can happen.
Babies born at 35 weeks have a pretty good survival rate with today's medical technology and knowledge and have a 0.8 percent chance of dying due to heart failure and other health issues.