Op you absolutely did the right thing in sending the other child home. You have them both a clear instruction not to go in that room and they knowingly broke it.
I can understand your frustration with your son as I would have expected him to have come to you and said something if his friend was breaking your rules. So accept that he may have had more to do with the writing than he is letting on - even if it's only agreeing with what was written or providing the pen.
I have banned pens from my own children's bedroom because of writing on walls and bed clothes. Anyone found breaking that rule has a further consequence added.
Moving on, yes, absolutely encourage your son to come to you when visitors are breaking your house rules. If he's not had many friends over, it's a learning curve for both of you. You may eventually get fed up of all the tell-tales for things that don't bother you, but it's easier to nip further misbehaviour in the bud the earlier you know about it.
I also wouldn't worry so much about leaving the children 'unsupervised'. The whole point of friends coming round is not to prove how much of a supermum you are with organised activities and wholesome snacks but for the children to play together and entertain themselves. At least in the circles my children's friends come from. We may provide one activity for the moment they suddenly become bored with everything else in the house, but it's not usually anything more complicated than Poundland craft kits for glueing or colouring.
Ultimately, it's a learning curve for everyone. Hopefully your friend isn't mad at you but realises you have boundaries which you will enforce no matter. Your son will respect your house rule as he knows you will send friends home and the other child knows that as well.
As for knowing handwriting, it is perfectly possible to have a 5 year old with legible handwriting. Privately (depending on what was written) I would be mindful of it for future visits. My own kids idea of rude words was writing 'fat' on their siblings bedroom wall. Rudely meant, but not swearing. If they were stronger terms then I would be having a chat with the parents about unacceptable use of language.
The writing will come off the wall with a magic eraser. If you are lucky and depending on the pens used, a good scrub with stain removal soap before washing will get most of the pen out of the bed clothes and hopefully the rest will come out in the wash. I'm currently washing biro out of fitted sheets after a literary outpouring!!!!