Why doesn't UK consider Ireland a foreign country for the purpose of British law? What is the philosophy behind it?
If we examine the history, it can be pointed out that more than half people in Northern Ireland considered themselves British and wanted to be part of the UK, while the rest wanted to join the Irish Free state to become United Ireland. This dispute was not easy to resolve. It happened that Northern Ireland was deemed UK territory for that time. Violent events followed and then came the Good Friday Agreement (I think everyone knows Irish history, so I am stopping here).
Considering this, a Common Travel Area was created wherein citizens of the UK and Ireland were not subject to immigration control and were not treated as aliens for the purpose of Immigration law. But the thing here to note is that if Northern Ireland was the chief reason for allowing Free Movement, then the UK should have allowed free movement from Northern Ireland, not the Republic of Ireland. But it is obviously the case that citizens of the Irish Republic who had absolutely no problem in losing British subject status or being a British citizen, were given free movement rights. And the British, who didn't really bother about all this chaos about NI, were granted the same movement rights.
What's more, the citizens of both countries are given rights that no 2 countries on the entire planet give to each others' citizens. (except obviously the European project; I am talking about countries which were not part of the EU (the EU didn't even existed then)). Why were such rights given to the people of the Irish Free State and the UK, when the whole debate was about the people of Northern Ireland? It were the Northern Irish people some of whom wanted to be with the UK and some with the Irish Republic. They could simply have given such rights to people born in or resident in Northern Ireland.
In British law, Irish people are not aliens (though they are not British). Similarly in Irish law, British people are not aliens (thought they are not Irish).
(1) The question: Why are British and Irish people not viewed as aliens in each others' countries? The whole issue was about Northern Ireland which was nicely solved by the Good Friday Agreement that granted the people of Northern Ireland the choice of claiming British or Irish or both citizenship(s), depending on which country they considered for themselves as "theirs". The whole issue was resolved by this. Why the extra special status?
For your information, Irish and British citizens have working rights, home student status (education rights), healthcare rights, free movement rights (without any condition like job offer or self sufficiency like the EU imposes), Social security rights, etc. in each others' countries. For a common man (and the majority of us are common people, aren't we?), these rights made effectively a common citizenship system if seen virtually. You're Irish? You have all the rights that people who are British have in UK without any conditions. You're British and you want to go and wander in Dublin and claim unemployment benefits? Well, you can and no one is stopping you!
(2) A consequent question would also arise: Is this practice of not viewing each other as aliens and giving equal rights in either country and the free movement right (due to CTA), all because of the Northern Ireland issue, or because of historically close connections? If the answer was "historical close connections", then it seems impossible to take away all the rights and end free movement in the event of Irish Unification. But if the answer was "because of Northern Ireland", then it is clear that all rights and special status and the free movement (CTA) will not be needed any more now that Northern Ireland has joined Republic of Ireland.
Some important documents that might help: