In both the Relay and Lobby services, join codes are used to allow other players to connect to a host. In Lobby, there are both public and private lobbies. Users can join public lobbies with either the LobbyID or with a join code. Users can only join private lobbies via join code. In comparison, there are no public and private Relays, and users will always need a join code.
To get a join code after creating a lobby, the host can access the Lobby.LobbyCode parameter, which can then be shared with other players. In Relay, you must perform a specific request for the join code by running Relay.Instance.GetJoinCodeAsync(allocation.AllocationId), which can likewise then be shared. See Relay vs Lobby to learn more about the differences between the two services.