In this parsha, derivations of the word yada, know, are used to indicate intimacy. When G-d decides to tell Avraham of his intentions to destroy Sdom, he says Ki Yedaativ, for I have known him. The word Yeedativ is used here to mean love, Hashem is saying that he has known Avraham that through his knowledge of him Avraham is beloved to G-d.
When the men of Sdom encircle Lot's house demanding his guests, they also use a derivation of yada. They demand that the guests be brought out to the mob, Veneida Otam. Here the word also involves intimacy but their intention is rape. In both usages an intimate knowledge is meant but in the first case it involves love for another that comes through knowing another, in the second it involves an assault for personal satisfaction.
In its first use G-d sees the goodness of Avraham and gives him special privileges and rewards. In the second use the men of Sdom are so threatened by generosity towards strangers, that they threaten cruelty towards them and Lot. This is the gap between those who give and those who take.
This parsha begins with Avraham sitting in great pain after his circumcision, in the presence of G-d when he sees three men whom he suspects of being idol worshippers; he nevertheless runs towards them and welcomes them and invites them in and serves them personally, though he had an entire household he could have delegated the job to. It is only after he has shown them hospitality that the angels inform him and Sarah that they will have a son.
They even inquire about Sarah's location. Why is her location important? If we look back we see that Avraham involves Sarah in the perperation of the food by going to the tent, by emphasizing Sarah's location in the tent, her involvement in Avraham's hospitality, they make the distinction between Yishmael and Yitzchak. Yishmael was also born of Avraham but born of a woman who would push her child away from her as he was on the verge of death. Yitzchak was to be born of Sarah who shared in Avraham's hospitality so that he would come from two parents and be the product of a family which was hospitable, who were givers.
Afterwards when Hashem discusses why he should tell Avraham the fate of Sdom, he emphasizes Avraham's descendants. The nation that will arise from him, who will practice Tzedakah U'Misphat, Righteousness and Justice. Why does righteousness come before justice here? Because without righteousness there is no justice. Law is meaningless without integrity and without charity as well which is the meaning of Tzedakah.
Both Sdom and the Philistines possesed law. Both Sdom and the Philistines followed their laws. Both Sdom and the Philistines are threatened with destruction and Avraham prays for both Sdom and the Philistines. When Avraham prays to Hashem for Sdom, he appeals to G-d saying, Hashofet Kol Haaretz Lo Yaaseh Misphat, 'Can It Be That The Judge of the Whole World Would Not Do Justice.' Once again the word Misphat is used.
Avraham goes through the list of numbers of Tzaddikim needed to save Sdom and none are found. Tzaddik is of course related to Tzeddakah and Sdom was renowed for its cruelty and its refusal of hospitality. At the heart of such cruelty is self-centeredness. Where Avraham was a Tzaddik, who gave to all exerting himself to the utmost, Sdom was the linear opposite. Avraham was a giver, the people of Sdom were takers. Sdom had Mishpat and not Tzedakah and so was destroyed. The angels visit Avraham and partake of his hospitality and in doing so condemn Sdom by its contrast.
When Avimelech, king of the Phlistim, appeals to G-d to save him and his people from anhiliation, he too appeals in a way similar to Avraham in questioning why G-d would destroy a righteous people and appeals, Hagoy Gam Tzaddik Taharog. Will You Also Destroy a Righteous Nation. Avimelech contrasts his people with Sdom, asking whether they will be destroyed like the wicked of Sdom. He argues that he acted within the letter of the law enstabilishing Misphat and yet G-d directs him to ask Avraham to pray for him to prevent his people's destruction. Only when Avimelech gives Avraham gifts does Avraham then pray for him and are they spared.
The Phlistim too like Sdom only had Misphat and allowed abuses to happen within the letter of the law. That is why Avraham states that there was no fear of G-d. They enforced a law but it was devoid of Tzedakah, of righteousness and of charity. It was a purely self-centered law that allowed the king to seize a woman as property if she wasn't another man's property. Like Sdom the idea here was 'what's yours is yours' and 'what's mine is mine.' It took charity, tzedakah, for Avraham's prayers for the Philistines to be succesfull.
The promise of Yitzchak was the promise of future generations which would practice both Tzedakah and Misphat and thus the promise of a better world brought about by following G-d. Lot who was prepeared to take great risks for hospitality nevertheless failed to influence others, even his own son-in-laws and thus like Noach, was saved along with his family but like Noach became drunk and resulted in damage to his lineage. By contrast Avraham and Sarah had built a legacy of influencing others. Lot's hospitality was purely physical. It was a hospitality of Misphat. He followed the law in giving physically to others but he lacked Tzedakah in giving them righteousness.
Misphat without Tzedakah leads to corruption and Lot's descendants, like Sdom and the Phlistim, became corrupted. His descendants in Midaan and Moav would then attempt to corrupt the Jews spirtually becoming sources of corruption. Tzedakah and Misphat and leads to the creation of a better world influenced by G-d. That is the legacy of Avraham who in this Parsha gives endlessly of himself. He loses his wife, he loses one son and then nearly loses another, time and time again he loses his home and the man who humbled kings is forced to wander himself and yet he continues to give everything up for G-d. Thus the parsha ends with the birth of Rivka and from there the continuation of the Jewish future with the birth of a woman whose destiny for Yitzchak would become apparent through her acts of selfless giving.