I can't give you a whole and thorough answer, but it often has to do with the emphasis you want to put. , "Give me the keys" is rather neutral. But "give the keys to me" means to me and not to X, Y or Z (who are around us).
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.