You will receive a form like this either before you board, while you are on the plane, or when you land. Fill out both parts. When you go through Mexican immigration, they will ask you for one part, and they will stamp the other one and hand it back to you. Keep it in a safe place. It identifies you as someone who has entered the country legally, and you will be required to turn it in when you leave Mexico. Immigration officials in a few airports are experimenting with an automated version of this process. Instead of the second part of the two-part form, you will get a receipt similar to the ones you receive at US automated Customs stations. That is the paper you should keep for your departure from Mexico.
If you lose the form, you can get a new one for about thirty-five US dollars at your point of entry. If you had a connecting flight within the country before reaching your final destination, that means you will have to apply for the replacement form at the airport where you first landed. To avoid this kind of delay and inconvenience, take care of that little piece of paper! Keep it with your passport or in a place where you can find it at all times.