This assumes that I don't know that the person I lend the phone to will use it for illegal purposes, that the illegal purposes are along the lines of corresponding and collaborating with other criminals and that I am based within the UK
On that exact fact pattern, I am unaware of any criminal liability.
The jury decides what the facts are based on the evidence and they are entitled to decide how they decide that including by the time honoured maxim “pull the other one, it’s got bells on it”. The defence of “the defendant says they didn’t do it” is rarely successful.
This is particularly the case where the jury is allowed to make a rebuttable presumption. For example, if your “friend” downloaded child abuse material. A jury is allowed to presume that the owner of the device knew it was there - a rebuttable presumption. You need to prove that you didn’t know - how are you going to do that?
Don’t lend your phone to people you don’t trust and be careful who you trust.
You say "I don't know that the person I lend the phone to will use it for illegal purposes".
The question is not whether you know, but whether you should have known. Let's say I, an adult person, unknown to you, offer you £250 to buy a cheap phone in your name and lend it to me forever. You don't "know" that I will use it for illegal purposes. But most people would assume that I'm willing to give you £250 for a £25 phone for a reason, and probably not a good reason.
If a crime is committed using your phone, the circumstances will be considered and police and judge will decide whether you were aware or should have been aware or willingly closed your eyes.