Shazam is an ancient wizard who is currently Lord Marvel (aka Marvel)
When Shazam was a young boy, some 9000 years ago, he was chosen by six long-since forgotten gods to become their champion!
The six gods were:
* Voldar* Lumiun* Arel* Ribalvei* Elbiam* Marsosh
These gods developed a magic code word formed from the first initial of their respective names.
At one point, Vlarem is seduced by a demoness disguised as a beautiful woman, and the two of them conceive two half-demon offspring, Blaze and Satanus, much to the displeasure of the gods. Vlarem later creates the Rock of Eternity from two large rock formations--one from Heaven and one from Hell--to hold the "Three Faces of Evil", a dragon-like demon, captive.
Shazam spent the next 3000 years battling evil but he grew weary and needed to choose a successor. Because the gods that he had relied on for his power had been long forgotten, Shazam petioned and choose gods, who would grant their powers to Shazam's successor. Shazam choose a worthy man named Teth-Adam. Adam merely had to speak Shazam's name and he was granted the powers of six Egyptian gods. But Adam's power soon corrupted him and he became less benevelant. Shazam renamed him, Black Adam but unable to strip him of his powers, Shazam banished Adam to the farthest star for his crimes.
Shazam once again waited to find a new successor. Unwilling to make the same mistake twice, Shazam decided to bestow his powers on a boy, much like what had happened to him. Ages past until Shazam discovered a boy worthy enough to be granted those mighty powers! Shazam choose young Billy Batson to receive the powers of six of the mightiest gods and mortals. When Billy Batson says the name "Shazam," he is transforned into an adult version of himself -- the world's mightiest mortal... Captain Marvel!
Although Shazam is killed--as prophesied--by a giant granite block falling upon him, Billy/Marvel can summon the ghost of Shazam for guidance by lighting a special wall sconce in Shazam's lair, the Rock of Eternity. More superheroes soon joined Marvel in carrying on the legacy of Shazam, including Marvel Family members Mary Marvel, Captain Marvel, Jr., and the Lieutenant Marvels.
Billy had many adventures as Captain Marvel but was eventually trapped by the evil Dr. Sivana in a sphere of Suspendium. This Suspendium trapped Captain Marvel, his frieds, and the evil Sivanas in suspended animation for twenty years!
Shazam waited patiently for the Suspendium to wear off, so that Captain Marvel could regain his title as the champion of the world. It was revealed at this time that Shazam and the Marvels lived in a parellel universe to Superman, Batman and the other Earth-One heroes. Captain Marvel's original earth was referred to as Earth-S.
A cataclysmic multi-universal crisis occured which merged the earths of Superman with Captain Marvel's and other heroes. It was during this time that Shazam and the Marvel's history was in flux. For a short time, while the newly formed universe was trying to realign itself, Billy Batson had a different set of parents, Shazam himself has a bit less caring and "Uncle" Dudley became Billy's real uncle!
This flux soon corrected itself and Shazam and his origin became similar to his pre-Crisis one. Shazam took up residence on the Rock of Eternity (a temporal spot in space/time) where he records the adventures of the Marvel Family.
Shazam has regained corporal form and for a brief time lived with Billy Batson so he he could regain an understanding of humanity. Sometime later Shazam gained godhood and joined Zeus, Ganthet, Highfather and the Phantom Stranger, and to form the Quintessence -- a group of all powerful beings who kept tabs on the order of the universe.
It seems that Shazam has gone back to the Rock of Eternity and still watches over his charges.
In Superman #216, Shazam called upon the Spectre to free Superman from being controlled by the demon Eclipso. This action broke a covenant between Eclipso and the Spectre, and set Eclipso permanently at odds against the wizard. Possessing the body of the Atom's ex-wife Jean Loring, Eclipso corrupted the confused Spectre into joining forces with her, and began a war against all magic-powered beings in the DC Universe.
Because of his previous action, Shazam was one of the duo's primary targets. In the Day of Vengeance miniseries, Shazam enlisted Captain Marvel to keep the Spectre at bay, while the wizard gathered all of his power to battle him. With the assistance of the newly-formed Shadowpact, a band of magic-based heroes, Marvel fought the Spectre nearly to a standstill, but the Spectre escaped and made his way to the Rock of Eternity to confront Shazam directly. The Spectre overpowered the wizard, absorbed his magicks, and killed him; and the Rock of Eternity disintegrated above Gotham City into "a billion pieces" and exploded, freeing the Seven Deadly Sins and sending a de-powered Billy Batson falling into the city.
Billy found he was still able to transform into the Captain before he struck the ground by saying the wizard's name as usual.
Captain Marvel has been revealed to be currently headquartered at the Rock of Eternity, acting in Shazam's stead.