Ainur
One thing that some people end up asking themselves when the read or watch The Lord of the Rings for the first time is "what makes this Sauron guy such a big deal?" or "so what exactly is this Gandalf character?" The answer to that is that they are Ainur, which could basically be considered Angels created by Eru Ilúvatar. They are spiritual beings who were created from Ilúvatar's thoughts before the beginning of time, each having their own free will and varying levels of innate power. They sung the world into existence and shaped it afterwards, for good or bad. Some of them went into the world and were bound to it, these are the Maiar, and had physical forms that they used to interact with the world, though these forms could be destroyed and their spirits "disembodied," which is the closest thing to death a Maiar can experience.
Valar
The strongest and most powerful Ainur to come to Arda and depending on how you look at them are either archangels or gods with a lower case g. There are thirteen in total, each one roughly corresponding to a particular "domain" analogous to Greek gods, though the Valar themselves do not claim to be deities of any sort (except for Melkor; more on him later). All the same, they're still highly respected by the Elves and Men of Dúnedain descent, and will oftentimes invoke their names in times of need.
The Valar ruled Arda from Valinor, aka the Undying Lands, from the beginning of time until the Second Age, when they relinquished control of Middle Earth to their creator Eru Ilúvatar, and Valinor became permanently separated from the rest of Arda.
They are:
- Manwë, King of the Valar and ruler over air and wind. Married to Varda, also Melkor's brother. The Great Eagles are Manwë's eyes and ears in Middle Earth. He is a very divisive character given the shit Morgoth (see below) gets up to to which his responses are either because of restrictions placed on him or because he is a lazy useless moron. Debate continues.
- Varda, Queen of the Valar and creator of the stars. Married to Manwë.
- Aulë, The Smith. Married to Yavanna, and creator of the dwarves (though he could only create their form, Ilúvatar later gave them life and free will of their own). Both of his best disciples went traitor (Sauron and Saruman).
- Yavanna, Giver of Fruits. Married to Aulë. Besides her domain being nature, she also created the Ents to protect the trees from over-foresting dwarves.
- Mandos, Ruler of the Dead, and the Doomsman. All dead elves and men arrive in his halls, whereafter they go to their separate fates. He is also the judge of the Valar, presiding over Melkor's trial and pronouncing the Doom of those who transgress the Valar. Married to Vairë. His real name is actually Námo.
- Vairë, the Weaver. Married to Mandos, and records all of history on her ever-growing tapestry.
- Oromë, the Huntsman and Lord of the Forests. He was the first to discover the elves and invite them to live with the Valar in Valinor. Married to Vana.
- Vana, the Queen of Flowers, married to Orome.
- Irmo, Master of Dreams, married to Estë. He would give prophetic dreams and visions to mortals in need. Together with his brother Mandos he is one of the Masters of the Souls.
- Estë, Lady of Rest & Healing. Elves who visit her and her husband's domain can recover from their weariness.
- Tulkas, Champion of the Valar, married to Nessa. He was the last to arrive in Arda, and was one of the few powerful enough to challenge Melkor at the height of his power, wrestling and imprisoning him with his own hands.
- Nessa, the Dancer, married to Tulkas.
- Ulmo, Lord of the seas, and the most proactive ally to the free peoples. One of the few to not trust Melkor in the beginning. As his home is not in Valinor but in the seas, he's the one who interacts the most with mortals.
- Nienna, Lady of Mercy, Grief and Compassion. She had been Gandalf's instructor, which allowed him to empathize with the free peoples, in particular the hobbits. Alongside Mandos, Irmo and Ulmo definitely the most competent of the bunch, given she was Gandalf's master and Gandalf basically carried the entire fight against Sauron on his back.
Of similar power but opposed to the Valar, is Melkor, aka Morgoth, the first Dark Lord and enemy of the Valar. Originally he was the most powerful of all the Ainur, but back during the music of the Ainur, he had become bitter that he could not create life on his own, and began rebelling against Eru Ilúvatar. Thereafter, he kept trying to dominate Arda to his will, corrupting it with his power and making war with the Children of Ilúvatar. Eventually, he'd spent enough of his power that he was captured and imprisoned by the Valar, only to be released when they thought he had been reformed. This was a ruse, and he continued to conquer Middle Earth throughout the first age, even causing the Noldor elves to rebel against the Valar just to get revenge on him. Melkor was finally defeated when the elves pleaded with the Valar to rescue them, causing him to be imprisoned beyond the boundaries of Arda until the end of time.
Maiar
The lesser Maiar take many different forms throughout the series, though many served under each of the Valar at some point.
- Gandalf, Saruman, Radaghast, Rámostamó & Morinehtar : See Below.
- Eönwë: He is the banner-bearer and herald of Manwë, and shares the chiefdom of the Maiar along with Ilmarë. Eönwë was sent to Middle-Earth, at the end of the 1st Age, to lead the Host of the West against Melkor, and it is said that it was he that overthrew that Ainu. After the War of Wrath, he went among the Númenóreans and, with the authority of the Powers and Eru, blessed that people with longer lifespan, taught them crafts and lore and brought flora and fauna from Valinor (including a seedling of the White Tree). It is prophetized that, when Melkor returns to destroy Arda, Eönwë and Túrin Turambar will slay him forever.
- Ilmarë: She is the handmaiden of Varda and, as said before, a chief of the Maiar. Unlike Melian, she remain in Valinor in content and nothing more is known about her.
- Melian: Noteworthy for being the progenitor of both the Half-Elves and the Kings of Gondor, she married the Elven king of Doriath and bore Lúthien, who would herself marry a human named Beren. As this shows, it was possible for Maiar in their physical forms to procreate with the Children of Ilúvatar, which has some interesting implications. She protected Doriath with her magic until her husband was killed by a bunch of angry dwarves, and eventually returned to Valinor heartbroken.
- Sauron: Formerly a student of Aulë but later was swayed to Melkor's side. Whereas Melkor used brute strength to impose his will, Sauron favoured guile and manipulation, especially when he successfully corrupted the kingdom of Númenor and brought about its ruin, or when he uses his Ring to dominate the wills of others. He's taken on other guises as well, such as "Annatar the Lord of Gifts" to deceive the elves, or the Necromancer of Dol Guldur when he was in hiding. Sauron poured most of his power into his ring, which allowed him to survive his initial disembodiment until the War of the Ring.
- Balrogs: All balrogs are maiar who sided with Melkor and took the form of fiery demons. The one in the Fellowship of the Ring is one of the last remaining ones; Melkor used to field armies of these guys.
- Boldogs: They were maiar that also served Melkor however, instead of taking shapes of fiery demons, they took the forms of Orcs. Of less might than the Balrogs, the Boldogs were still powerful and were usually in positions of field commands of the Orc forces.
- Ungoliant: The mother of Shelob the giant spider, Ungoliant herself was an even more massive spider monster who birthed all other giant spiders in the world. Ungoliant hated the light but also gained power from consuming it, so she temporarily allied with Morgoth to destroy the Two Trees of Light. When their alliance was dissolved, she nearly killed Melkor for trying to hide the Silmarils from her, but his Balrogs had to come in and save him. She eventually became so hungry that she ate herself.
- Arien & Tilion: these two became the bearers of the Sun and Moon, which were the last fruit & flower of the Two Trees of Light that Morgoth killed. Arien was one of the fire spirits that Morgoth couldn’t sway to his service, and she is said to be the second most powerful maiar. Tilion is not as powerful, and more wreckless, resulting in the phases of the moon and eclipses. He is said to be the Man in the Moon and Arien’s lover.
Istari
The Istari is the formal name of the Wizards, all of whom were Maiar who were sent to Middle Earth to aid the free peoples and provide them with wise counsel, during the Third Age between Sauron's initial defeat and his final one. Though they appear to take the form of elderly men, they're still quite powerful in their own right, both physically and in magic.
Istari are the order that Curumo (Saruman) and Olórin (Gandalf) belong too. There are five of them in all. They were sent by Manwë to inform mortals about Melkor's lieutenant Sauron and raise forces to oppose him. Readers only learn to what happened to three of them. Saruman got corrupted by Sauron after learning about the nature of his rings, but was eventually killed after he sided with Sauron and lost all of his power and authority in the War of the Ring. Radagast made friends with the Giant Eagles and preferred to tend to nature than help the free peoples directly. Gandalf the Grey initially led the Fellowship until he was pulled down to the bottom of dwarf mines of Khazad-dûm by the Balrog, Durin's Bane. Fought and chased the bastard its Endless Star for days & died after killing it. The battle itself destroyed the tower at the top of the peak. He was then upgraded to Gandalf the White by Ilúvatar and fucked off to the Undying Lands after the War of the Ring. As for the two "Blue Wizards," we're only given scraps of speculative information, that they headed East into the lands where Sauron held sway. One version says that they ultimately failed in their mission. Another, however, says that they were successful in creating uprisings and staying the forces of the East, to the aid of Sauron. Along their mission, they also created schools of magic. Regardless of whether the Blues succeeded or failed, they and Radagast likely returned to Aman as well.