From a theological perspective, the first acts of hospitality were not from human to human - they were from God to man via creation and His grace in the aftermath of the Fall. The specificity of the universe, its fine-tuning and precision, are the first and most excellent examples of creating an environment for guests that makes them feel at home and frees them to interact with God. In the Fall, we see God’s graciousness (which is the root of all hospitality - the extension of grace to the weak) in the fact that he provided clothes to cover their nakedness and a closing off of the Tree of Life to ensure that mankind wouldn’t die in sin. The implications of both of these acts formed a clear through-line for Semitic culture and history: human life is precious, and must be cared for and shown grace. This belief was codified in the Mosaic Law with its statutes on how to treat strangers and sojourners among the Nation of Israel. Ironically, the Mosaic Law affirmed this value with its code of eye for an eye.
From a sociological perspective, hospitality is a bedrock of the middle eastern culture because only by caring for others could societies, or even individuals, guarantee their survival. The harsh, arid climate, coupled with the nomadic lifestyle of many of the early residents of the region, made kindness towards guests an imperative. To deny a traveler hospitality - whether it be someone familiar to you or someone completely unknown - was to deny them life. Like any society, a mutual understanding arose that those who were in need could find relief at any house, and would repay the kindness whenever a stranger or guest came knocking at their door. Hospitality then finds its root in the quid pro quo of mutual survival; a willingness to see the value in another life because your life is bound to it, even if not obviously so.
How hospitality took root in ancient Middle Eastern cultures:
There’s a couple of scientific ways of approaching this - one is cultural transmission, and the other is memetic theory. Cultural transmission is simply the process by which an idea or value is transferred from one generation to the next; it’s essentially the study of how parents pass their values on to their children.
Memetic theory is a different animal. Richard Dawkins first proposed it in his book The Selfish Gene in 1972, and it views information or ideas (memes) as living organisms that seek to reproduce by offering value to their host. It’s essentially Darwinism for ideas. However, it holds a lot of insight into how ideas are transmitted.
In the case of hospitality, it is easy to see how it’s transmitted within the Jewish culture: it’s written into the Mosaic Law, it’s practiced as part of their religious duties, and it’s become a foundational idea that is so ingrained into each coming generation that it is simply too strong to fall out of favor (being inhospitable produces more discomfort than being a good host does).
That doesn’t explain the transmission of the idea across cultures in the Middle East, which is where Memetic Theory comes in. Because the idea of hospitality proved useful in an evolutionary sense (it helped keep people alive by binding them to one another), the idea was easily transferable within the harsh Middle Eastern climate. Since the essence of hospitality was (and perhaps still is) the invitation for strangers/aliens (those who are not of your people) to join your tribe for even a little while in order to stay alive, it’s easy to see how the idea could take root and exponentially flourish.
The Hebrews were the source for this hospitality in the sense that they codified it and made it part of their religious practice. The central passage in the Law for the treatment of strangers/aliens/visitors was Leviticus 19:33-34:
This equivalency (and the corresponding expectations for foreigners among the Hebrews, cf. Lev. 17:12-13; 18:26; 19:10; Num. 15:16) meant that grace towards all was expected from each household and the individuals therein.
Because of the law, what might have otherwise been just an after the fact survival mechanism became a cultural standard that influenced behavior, inter-tribal and inter-national relations, and the survival of various ethnicities. It also allowed for an unpredictable region to not only be inhabitable but effective for prosperity.
I think the imperative for hospitality is carried into the New Testament church. In fact, the book of Acts shows that the church practiced radical hospitality, only they did it not just as a means of survival or religious devotion, but as a communal act of worship (the distinction being that religious devotion can be hurried, whereas worship comes from a sincere motive). Hospitality opened doors not only physically, but within the spiritual realm - thus the warning in Hebrews 13:2 to not neglect hospitality to strangers, because by doing so some entertained angels without knowing it (an appeal back to Abraham in Genesis 18:1-15).