Hamunaptra (The City of the Dead) which was an ancient necropolis holding the remains of Anck-su-Namun and Imhotep.
In addition to the acheological interest there was a considerable amount of treasure in the ruins in addition the Book of the Dead and the Book of the Living.
From the Rickipedia
Hamunaptra was an ancient lost city that served for many centuries as the resting place for the Pharaohs of Egypt and their wealth. The vast necropolis contained precious artifacts and antiquities from the wealthiest of Egypt's Pharaohs, as well as their remains, and was guarded intently by the Pharaoh's elite guards, the Medjai in ancient times and for centuries into modern times
Rick was there because (per Wikipedia)
In 1926, Jonathan Carnahan presents his sister Evelyn, a Cairo librarian and aspiring Egyptologist, an intricate box and map, which leads to Hamunaptra. Jonathan reveals he stole the box from an American adventurer, Rick O'Connell, who encountered the city while in the French Foreign Legion. Rick makes a deal with Evelyn to lead them there if they release him from prison.
Beni because he was guiding a band of American treasure hunters.
As for what was being defended, the city was fiercely guarded by the Medjai warriors and by warrior priests to prevent the rise of Imhotep.
Rickipedia
The Medjai are warriors devoted to preventing the rise of evil on the Earth, specifically, the resurrection High Priest Imhotep. The Medjai guard the ruins of the City of the Dead Hamunaptra, to guard against anyone who might the [sic] [break the?] curse or rob the treasures of the pharaohs.
As for why the French Foreign Legion were there at the start of the film, this is also explained at the Rickipedia.
A garrison of the French Foreign Legion led by Colonel Guizot, an officer placed in charge of the troops, had believed so much in Hamunaptra, which was said to be nothing more than a mere myth, that they had, without orders, marched through Libya into Egypt to find the ruins in the hopes of taking some of the treasures contained within.
There thy are attacked by a marauding horde of Tuareg warriors that had manuevered the garrison that occupied Hamunaptra in such a way that they were open to an ambush attack.
So the city wasn't under attack, the Legion was and were defending themselves.