How does Legend ranking work?

Let’s say I reach legend, what rank should I get? Is it based on how many people got legend before me or is there mmr behind the scenes?

Both rank number and your hidden MMR are considered in legend rank for matchmaking.
And hitting legend early in the month will place you ofcourse in the top.

cant post links so here is the explanation below:

There are two matchmaking pools: matchmaking by rating (i.e. by MMR) and matchmaking by rank.

When playing with a Star Bonus greater than one, players are matched by a hidden Ranked matchmaking rating (MMR). This means that all players playing with a Star Bonus will always be matched against players who are close in skill level to them, until the player climbs to a rank which causes the player to run out of Star Bonus. *
Once a player runs out of Star Bonus, they will start matching with opponents by rank and not by MMR.
The matchmaking system, however, can accept looser matches if necessary in order to ensure players are not left queueing for too long.

Players at Legend rank are matched according to the same hidden Ranked MMR.MMR is in fact tracked during all Ranked Play activity, and it is used whenever matchmaking involves at least one Legend rank player.
MMR also determines the player’s initial numbered seeding upon reaching Legend rank.
While the system aims to limit “Legend vs sub-Legend” matchings as much as possible, Legend rank players are sometimes inevitably matched against sub-Legend players due to compromising calculations in MMR matchmaking.

MMR calculations in Hearthstone are highly specific to the game. They are complex and do account for different amounts of playtime over time, among many other factors.
Matchmaking rating is not reset at the end of every season.

It’s that months mmr that determines your current legend rank, you won’t enter at the very bottom in other words (just in the low part)