There are a number of reasons why passports are stamped. The primary reason is to create an easily-viewed record of someone's movements, without having to create a pile of paperwork that someone might be forced to lug around. Different countries have differing policies on passport stamping. In the European Union (EU), for example, the passports of EU citizens are not stamped when traveling between EU countries, as part of the EU's open travel agreement.
Many people who have traveled internationally are fond of the ritual of getting their passports stamped at the border. The stamps provide a memento of a trip that can be shown to friends upon return, and getting a stamp has an official air about it that some individuals enjoy. Many people really feel like they are traveling internationally when the customs official is stamping their passport.
Passport stamps are not provided for the enjoyment of travelers, however. They provide proof that someone has entered a country for a set period of time, with most stamps indicating the type of travel, the amount of time the person is permitted to stay, and the date of the stamp. If a foreign national is stopped by police, the information may be used to determine whether or not the traveler is legally in the country. Many countries also use exit visas to indicate that someone has departed, so that visitors cannot be accused of overstaying their entry visas.
There are some political issues connected to passport stamping, as well. For example, some countries do not allow their citizens to travel to certain other countries. If a citizen re-enters his or her home country with a stamp from a forbidden travel destination, it can be used as a reason to initiate legal proceedings. This concern often leads travelers to try and avoid getting a stamp when they are entering illegal destinations; for example, American citizens may smuggle themselves into Cuba so that they can visit and avoid the penalties for breaking the embargo.
Many visas come in the form of passport stamps, with the issuing nation believing that it is easier to keep track of visas in passports than in separate documents. People can also get stamps to provide legal proof that they entered or exited a particular country, as might be required when a citizen is applying for a visa extension. They are a type of legal document of sorts, and defacing or attempting to remove them can render a passport invalid. For frequent travelers, insert pages for additional stamps are provided by the agencies that issue passports.