Basically, 'in + time' refers to a specific point in time after the present. For example, if it's 5:00 and I say something will happen in five minutes, I mean it will happen at 5:05.
'For + time' refers to a duration of time, rather than a specific point. When something is taking place over a period of time, use 'for'.
Ex:
"We will stay for five minutes" roughly means "We will leave in five minutes".
If you say "we will leave for five minutes", it implies that it'll take you five minutes to leave!
"We will stay in five minutes" doesn't make much sense, because it means that five minutes after the present you'll start to stay (which doesn't make sense if you think about the definition of 'stay').
It's the exact same for 'a short time'.