Everyone on the same island/realm can chat with everyone else in the 'Global' chat room. If you are a member of an alliance you will also have an alliance chat room and finally, you will have a chat room for every other player you have sent a message to. 

Rooms are sorted by the age of the newest message. If you have notifications enabled in settings you will be notified whenever someone sends you a 1:1 private message. Only alliance members can see the chat in the alliance chat room and only you and the other player can see the messages in the 1:1 chat rooms.

You can hide a 1:1 chat room by dragging it to the left and selecting "Hide". This does not hide it for the other player and if they message you again it is unhidden. You can also unhide it by going to their profile page and selecting "Message".