Starting with the Captain Britain story in The Daredevils #7, the main continuity in which most Marvel storylines take place was designated Earth-616, and the Multiverse was established as being protected by Merlyn.
New universes would also spin out of storylines involving time-traveling characters such as Rachel Summers, Cable, and Bishop, as their actions rendered their home times alternate timelines.
Some can seem to be taking place in the past or future due to differences in how time passes in each universe.
According to the origin mythology, at the beginning there was only one universe, The First Firmament, but due to actions of Celestials existing there, it diverged.
[1] Then, the Multiverse went through several incarnations and eventually the Big Bang caused the existence of the Seventh Cosmos, where most well-known heroes originated.
The seventh iteration of the Multiverse was destroyed as a consequence of the phenomena known as incursions and was eventually reborn as the eighth thanks to Reed Richards.
This was apparently retconned during the "X-Men: Messiah Complex" storyline, where Forge stated that all mutants in possible future timelines were depowered, not in parallel universes.
Not every alternate dimension is an entire independent universe, but instead maintain a parasitic relationship to a parent reality.
For example, beings like Dormammu and gods like Odin hail from separate dimensions, but they all nevertheless belong to Reality-616, and other realities like the MCU, have different variants of these characters.
In addition, many universes have also been designated with numbers by fans with various methods for the numbering, such as the birth date of an important Marvel staff member (artist Nelson Ribeiro for the Transformers U.S. Universe, Earth-91274) or the spelling of a name with a touch-tone phone (Animated Silver Surfer Earth-936652, spells out Zenn-La).
In 2014, during the publication of the "Spider-Verse" storyline, writer Dan Slott posted on Twitter that the numbers that appear in wiki entries and handbooks do not count, only those that are published within "actual" stories do.
This was in response to the questions that the different numbers for some Earths appearing in Spider-Verse brought up, such as the Spider-Friends being from Earth-1983 and not the believed designation of Earth-8107.