These are the Infinity Gems. They have a long history in Marvel Comics, beginning in
Marvel Premiere #1 (February 1972), when the Soul Gem first appeared. The rest of them appeared during
The Power of Warlock (1972) and were originally called Soul Gems as a group. In
The Thanos Quest (1990), Thanos changes the name to Infinity Gems since only one of them controls the soul.
In the MCU, Infinity Stones (note they're not called gems) first confirmed to exist in
Thor: The Dark World (2013). However, that's not the first time one appeared.
The Tesseract (aka the Cosmic Cube in the comics) was first mentioned in
Iron Man 2 (2010), first appeared in the post-credits scene of
Thor (2011), played a major role in
Captain America: The First Avenger (2011), and then was first confirmed as an Infinity Stone in
Thor: The Dark World (2013). At some point, probably in an interview, the Tesseract was confirmed to be the Space Stone.
The Aether first appeared in
Thor: The Dark World (2013). At some point, it was revealed to be the Reality Stone.
The Orb first appeared in
Guardians of the Galaxy (2014). It was confirmed to be the Power Stone.
The Mind Stone first appeared (sort of) as the Scepter in
The Avengers (2012). The Mind Stone itself was first alluded to in
Guardians of the Galaxy (2014), and then first appeared in
Avengers: Age of Ultron (2015). As the gem that powers the Vision, it was combined with the Sunstone from the comics.
The Time Stone was first alluded to in
Guardians of the Galaxy (2014), then first appeared as the center of the Eye of Agamotto in
Doctor Strange (2016).
The Soul Stone (which is orange) has not appeared yet.
As you may have noticed, the colors of the Infinity Stones do not match the colors of the Infinity Gems. Keep that in mind below.
In the Marvel Universe, the universe was rewritten following Secret Wars. In practice, this doesn't mean much. No previous Marvel stories have been erased from existence. But it does allow them to change a few things going forward, and one of those changes is that Infinity Gems are now Infinity Stones. Other properties have changed as well.
They started reappearing in
Marvel Legacy #1 (September 2017) with this blue stone.
The next one to appear was this giant purple stone in
Guardians of the Galaxy #147 (November 2017). The writer says it's so big because of how much energy it has, but that it can be compressed.
Captain Marvel #126 (November 2017) debuted the next stone, a red one that was found in another reality.
The most recent one was also the first to be specifically named: the Time Stone. As you can see, it is now green. It showed up in
Thanos #13 (December 2017). Interestingly, only a piece of it has been found so far, and it was found in the future.
Infinity Countdown Prime #1 (February 2018) shows that Turk Barrett has the Mind Stone...
...and Magus has the Soul Stone, until it's taken by Ultron.