Out of curiosity: how likely is it that you end up in a foreign
country with your passport inside your checked-in luggage, and are
there specific safeguards in place to prevent that?
There are no safeguards against you checking in your passport with your luggage; other than the practical sequence of events (as you mentioned) that the passport is required before the luggage is sent onto the cargo hold.
Would the immigration control ever allow you to leave without showing
your passport when it's needed in the destination country? Say, could
I get out of the EU on my regular ID card, with a non-EU destination?
Only if your EU card was valid identification at your destination country. So, to answer your specific question - no they would not. They would check your boarding pass (assuming you haven't checked that in as well), and based on that know your destination and based on that, ask for specific documentation.
And finally, should I have managed to arrive under such conditions at
my destination, what would happen there? Would I somehow be allowed to
retrieve my passport, or would this be handled as if I didn't have a
passport at all?
If you managed to arrive at your destination without anyone checking your passport (strange, because it is checked at the gate on all flights that I have flown from the EU to non-EU destinations); you cannot (legally) cross the border as you are (in effect) an undocumented immigrant.
You would have to beg the mercy of the immigration control officers, the airline, and the airport security to allow you access to the (unsecured) baggage claim area, where you could possibly claim your bags and retrieve your documents.
Assuming, of course, your bags arrived on time and weren't offloaded or otherwise misplaced.
In a (more plausible) event that your passport was stolen in the airplane or otherwise lost; and you don't have any copies of the passport with you:
You would have to identify yourself somehow to the authorities. If you have your EU card - this at least lets them know your citizenship and where you send you back (to).
You are not an illegal immigrant, but you are an undocumented immigrant; I use the word immigrant here because it is assumed that you are trying to immigrate; although practically it makes no different the purpose of your trip (as, the only way to verify that is the nature of your visa (if it was required)).
If you normally do not need a visa to enter the destination country, you may be allowed to enter on an emergency travel document; however, the issuance of this depends highly on the immigration procedures at the destination country. For example, if no stamp is required as proof of entry, they could (possibly) log you as entered under the details available on your ID.
You would then have to apply for emergency travel documents at the embassy, and return back immediately. You cannot go on your holiday on this entry type; because it is generally restricted to a few hours or days - basically, enough time for you to get to your embassy and get things sorted out.
If you normally do need a visa to enter the country, your details would be logged, you would be taken to the detention center for illegal immigrants. You may possibly be taken to court to face a judge who may decide your actual status; and then finally you would be deported back to your country of citizenship (if you had documents to prove the same). If you don't have any documentation at all, you would be held in the immigration jail until arrangements could be made to either [a] identify your nationality or [b] deport you to a third country.
A similar situation (missing passport at destination) actually happened to a friend of mine, who had a newborn son in Canada and was able to fly out of Canada without a passport for his newborn (just the birth certificate). On returning to Canada, he was stopped at London because his newborn was not allowed to board as he didn't have a passport.
After much haggling with the border control officers, they allowed him to enter the UK with his son and wife (as they were both Canadian citizens); they went to the Canadian embassy and got a passport issued for their son, and were then allowed to travel on.
So yeah, not a fun experience and I would take the above as "normal" either.