Hey leonarr,
From the looks of your screenshot, it seems like there was an issue with Mojang's Realms servers. The error message you are seeing is HTML code for a webpage with the title "Service unavailable", which typically means it's an issue with the server itself rather than your client.
According to Downdetector, it looks like Minecraft did experience an outage yesterday around 10 PM, which could explain the difficulties you faced. It might have only been a partial outage, meaning your friend might not have run into the same problem because their connection was routed to a different server that was still working.
My suggestion would be to just wait a little while and try connecting to the Realm again later.