Note: I have seen people suggest that if you can replace “in to” with “in order to”, you need the space. However, “in to” is NOT interchangeable with “in order to”. There are contexts in which “to” can be replaced with “in order to”. But if you have a verb phrase that includes “in” (e.g. gave in) followed by “in order to”, you would need to have the word “in” twice. If we continue with the example of the boy who gave in to peer pressure: “He gave in to avoid being bullied further” MEANS THE SAME AS “He gave in in order to avoid being bullied further.” In both cases, the “to” is the beginning of the infinitive. If you had replaced “in to” with “in order to” the meaning would change. If you say “He gave in order to avoid being bullied further”, it would mean the boy gave something to someone for the purpose of avoiding further bullying. What he gave is not specified, but it was possibly his lunch money, or the answers to his homework. Giving to avoid bullying DOES NOT MEAN THE SAME AS giving in to avoid bullying. He might be giving in to the pressure to take drugs or to steal something. (In those cases, “giving in” is not only not the same as giving, but actually means taking.) So “in to” cannot be replaced by “in order to”, but if the “to” can be, you know you need the space.
I know this is a bit of a brain twister. Please ask any questions you have, and let me know what I need to say more clearly.