Hebrews 13:2 says we may have possibly entertained angels and not known it. What would God’s purpose have been for doing this? Is it some sort of test? God knows the end from the beginning, (in this case knowing the outcome of the meeting as far as what our reaction to, and our treatment of the angel will be). So, could it be that we are to learn something from him? This has always intrigued me and I really don’t have a clue as to why God would set up this meeting.
I don’t think its a case of God testing us to see how we’ll behave. Like you said, He already knows that. I think the writer was reminding us to be kind to strangers. He said there have been times when an apparently ordinary person who showed up to help someone in a time of need and then was gone as suddenly as he or she appeared was actually an angel sent by God to render assistance. Hebrews 1:14 tells us all angels are ministering spirits sent to serve those who will inherit salvation.
The writer’s point was that we really don’t know who (or what) a stranger is so we shouldn’t automatically be suspicious or dismissive when someone we don’t know offers to help.