Many countries require a passport to be valid for six months. Sometimes these six months are counted from the date of departure, or from the date of entrance. Even though some of these countries only legally allow you to stay for 30 days or three months. What is the reason such a requirement is in place in many countries?
When it boils down to it, provided all your travel plans go well, it may not be a problem.
The 6 month limit is possibly a bit long these days, and indeed only some countries insist on it, but it's there, and it's there for when things go wrong.
Every country is trying to get tourists (well, maybe not Saudi Arabia), but to not break the law. You're only allowed into a country with a valid, legal passport, and sometimes a valid visa.
Now, if your passport is expired, suddenly you have an unlawful situation. Your own country effectively says your document is not a valid document. So now said foreign country has someone without a valid document. How do they get you home? Unless you're neighbours, and can just pop across the border, it's now nearly impossible to leave the foreign country, as you'd have to travel through another country which won't accept an illegal document. Indeed, some European countries allow you to return using just a national id card.
Airlines, if they let you travel without a valid visa/passport, are made to bring you back at their own expense. So they won't want to take you either. Indeed for Australia, it's not mandatory that you have the six months, but they warn you that some airlines enforce it, nonetheless.
So now that we have a reason to not allow people to have their passports expire while in the country, why six months? If I'm there for 2 days, and the expiry is 6 months later, why should they care?
First, a lot of the countries that have these limits, offer six month visas. Meaning you could stay right up to the day of departure. So that's one reason.
Now, every day that you get closer to departure risks you having an invalid passport if you overstay even a day.
So for most countries, just having an arbitrary limit aims to prevent this issue. If you're suddenly in a car accident and can't fly out, or, heck, even if your flight is delayed a couple of days, it's best for all involved that nobody's passport expire as a result. Otherwise, legally you become an overstayer, and by law they'd have to deport you, which could be tricky if you're ill. Imagine the situation where you're stricken with, say, swine flu, your passport has now expired, and you get deported. On top of this, you're also considered an overstayer, which will be on your permanent record, and in some the case of some countries will almost certainly preclude you from returning.
Not every country has this six month limit. Many just require you have a valid passport while there. NZ and a few other countries enforce a 3 month rule, although apparently for people from the UK, NZ states that you only need a month free after your visa ends. Each country deals with this in a different way, but the 'six month rule' is common and simple for all involved to understand.
It's just a technicality, I really don't see how it puts an approved destination country in any kind of real jeopardy. When you have a passport expire while abroad you don't magically turn into a different person or a criminal. It's just a paperwork bs technicality based on nonsense laws.
If your passport does or will expire during your trip, you usually have access to consular services or an embassy from your country which will be able to help you. Yes it's a hassle, yes it's expensive. But how many times has this occurred in the past to have these laws put in place? How many times has this happened vs the number of visitors in a year? A more realistic rule would be that your passport has to be valid for double your length of anticipated stay or a minimum of 30 days. If I'm going to Vegas for three days, it's unrealistic in my opinion to demand my passport be valid for six months.
Some domestic air carriers used to or still do accept expired documents as valid id. You are still the same person you were last week when your passport was not expired. Having passports expire any sooner than 10 years is a money making scam in my opinion. Some countries have 20 year passports (I guess 19.5 according to some places) and it works well for them. I'm not happy that our five year passports are actually four and a half year passports.
I posed your question to our local passport office a few years ago as I had the same concerns and questions. My above response, in part, was the gist of our conversation. When I emailed them, I got a totally different response.