Every country has laws about who can get passports. In countries without proper rule of law this is often arbitrary. Does that mean all those countries have made emigration illegal?
> If the law also says you can't leave without passports, like Chinese law,
Other countries don't let you in without a passport. Even in the absence of a Chinese law, an airline would deny you boarding if you didn't have a passport.