And the two angels came to Sodom in the evening...And Lot saw and arose toward them...And he said, "...please turn to your servant's house and stay overnight."...(Bereishis 19:2)
We know the famous Midrashim that tell us how the people of Sodom would punish those who do kindness to others. And we see from the pesukim above that Lot invited guests to his home in Sodom and offered them much kindness.
What made Lot take the risk of inviting guests to his home?
Rashi says, “From Avraham’s house he learned to look for wayfarers.” How did Lot learn it? By observing Avraham himself doing it all the time, it became part of Lot’s nature to such a degree that he could not hold himself back from inviting the guests in Sodom, even in the face of danger. This teaches us that being an example for others has a very powerful influence on the observers, if they see the righteous act being performed again and again. They learn from the observation of the good character trait and it becomes part of them.