I see three issues at stake in your question. First, these people need to be saved. You and your friend should be witnessing to them about Jesus Christ and Him crucified. You should explain to them the consequences of sin and the payment Christ made for them. If they reject the gospel message, you may find your problem of whether or not to separate from them solved. They may separate from you. However, if you call out to God for their souls and trust in His help as you approach them, you may find that one or more of them will trust in your Saviour. And, after all, is this not the purpose of God bringing us into contact with the lost in this life? Tell them with love that a Saviour loved them and see what God will do.
Second, there is the issue of living together. This is certainly immoral. Consider these verses:
Exodus 22:16-17 And if a man entice a maid that is not betrothed, and lie with her, he shall surely endow her to be his wife. If her father utterly refuse to give her unto him, he shall pay money according to the dowry of virgins.
1 Corinthians 6:15 Know ye not that your bodies are the members of Christ? shall I then take the members of Christ, and make them the members of an harlot? God forbid.
Hebrews 13:4 Marriage is honourable in all, and the bed undefiled: but whoremongers and adulterers God will judge.
God established that physical relations should occur only within the context of marriage. All else is a perversion of the ways of God.
Third and finally, what level of friendship can you carry on with people who insist in open sin? The simple answer is that you can maintain a surface level friendship for the purpose of reaching out to them, but you should not make them close companions. Proverbs 13:20 states, "He that walketh with wise men shall be wise: but a companion of fools shall be destroyed." Therefore, close companionship should be avoided. This is the level of closeness which ends in friends acting like one another. You should not run around with them to the places they frequent. You cannot be close friends without becoming a bit like them.
However, this does not mean that you cannot have any friendly relations at all. Paul wrote, "I wrote unto you in an epistle not to company with fornicators: Yet not altogether with the fornicators of this world, or with the covetous, or extortioners, or with idolaters; for then must ye needs go out of the world" (1 Corinthians 5:9-10). In other words, we can keep a certain level of company with the people of this world. We can sit down to a meal with them or other similar things. This gives us an opportunity to be a witness to them--both in our actions and in our verbal witness. If you can keep your testimony and not be influenced wrongly, limited time with the lost can be a way to reach them.
As I said from the beginning, your main focus in your relations with those who do not know Christ should be your concern for their souls. If you make this your priority, most of the other concerns will work themselves out.