How early is ok?

How early is it safe to give birth? not everyone makes it the full term of 40 weeks... some are earlier, some are later... so this got me thinking... how early is too early to be safe?