Although legal permanent residents of the United States (green card holders) have gained a special status that many envy, not all of them want to live in the U.S. forever. If you have decided to live somewhere else in the world, you might, for the reasons described below, wish to file a Form I-407 ("Abandonment of Lawful Permanent Resident Status").
If you move to another country with the intention of making it your primary home, you will be considered to have given up your U.S. green card, and won't be allowed back in to the United States.
This can happen in as little as one day (contrary to popular myth). However, it is true that, if you stay away from the U.S. for more than six months and attempt to return, you're likely to face questions about whether you abandoned your residency; and if you stay away for more than a year, you will be presumed to have abandoned your residency, and face a tough time arguing to be let in to the United States.
So, trying to hang onto your green card after moving to another country could mean that you ultimately waste time and money in any attempts to travel to the United States. You might just be turned around at the border or airport and sent home.
After you file an I-407 to voluntarily give up the green card, your situation will be much clearer. You'll still be able to apply for entry visas for short trips to the United States. And if someday you want to apply for a new green card, the fact that you voluntarily abandoned your residency earlier will not be held against you. (Do not assume, however, that you can simply get your old green card back. It might be that you no longer qualify for it.)
Another reason to give up your U.S. green card if you're actually living in another country is that you'll most likely free yourself of the obligation to pay U.S. taxes. Speak to a tax professional, however, to fully understand the implications of such a move.
An I-407 form allows a legal permanent resident to officially abandon their status. You would need to submit it to USCIS by mail, along with your actual green card (but no fee). See the instructions and form on the USCIS website.
When you get a confirmation from USCIS that it has taken action to cancel your green card, this will help you in the future if you're applying for a U.S. visa or entry, to avoid confusion about your earlier status.
Yes, in some cases an immigration official at the border will note that a permanent resident has been out of the country for a lengthy period of time. The officer may advise the person to file an I-407 and abandon their residency. However, the person cannot be required to do so unless there is sufficient evidence that they have actually established residence outside the U.S. or they have broken immigration or U.S. laws.
If you plan to be out of the U.S. for an extended length of time, you don't necessarily need to give up your residence. You can apply for what's known as a reentry permit. With this, you should be allowed back in the U.S. at the end of your stay. Reentry permits can be used for absences of two years at a time. To apply, follow these instructions for submitting USCIS Form I-131, which form is available for free download on the USCIS website.
You should contact the U.S. consulate in your country and explain the situation. They are most likely to be sympathetic if you can prove that circumstances beyond your control arose, such as a health issue or the death of a close family member. The consulate can issue you a special visa for returning U.S. residents.