In Classical legend, Damocles is an attendant to the tyrant Dionysius II of Syracuse. When Damocles comments that Dionysius must be very happy to hold so much power, Dionysius offers to switch places with him. When Damocles accepts, Dionysius arranges to have a sword suspended by a hair over the throne so that Damocles might experience the constant sense of danger powerful people must endure. Damocles, who had initially enjoyed the magnificence of the role, finds he cannot be happy with that threat over him and asks Dionysius to let him go. (A translation of the full anecdote from Cicero’s Tusculan Disputations can be found here—search for “Damocles”.) So the sword of Damocles symbolizes either (1) the constant threat powerful people face, or (2) a looming threat that prevents one from being happy.
The latter interpretation is more relevant when it comes to use of sword of Damocles in this century (and the phrase has been modish for the last few years). Writers often use it to refer to any looming threat, and while it often appears in relation to powerful people, that they are powerful usually isn’t relevant to the meaning of the phrase.
Examples
[A]ll lived with the fear of ridicule, like the sword of Damocles, for ever before their eyes. [The London Literary Gazette (1828)]
There is something hideous in the contemplation of these hidden dangers—these terrible things suspended over our heads in the midst of festivity, like the sword of Damocles by a single hair. [“Consumption,” Theodore Sedgwick Fay (1831)]
Impeachment, too, like the sword of Damocles, hangs over the President, Vice President, and all civil officers of the United States. [Notes on the Constitutional History of the United States, Kenneth McIntosh (1877)]
As it was, conscription remained a sword of Damocles, suspended over but never descending upon the head of Ireland.[Ireland in the Last Fify Years, Sir Ernest Barker (1919)]
Graham told the crowd that the entire human race has a sword of Damocles hanging by a hair over its head. [AP via Eugene Register-Guard (1963)]
Quebec has been holding a separatist sword of Damocles over Canada’s head for much of the past 30 years. [The Independent (1998)]
A proposed anti-subversion law, which would put limits on speech and publication freedoms, is hanging over our heads like the sword of Damocles. [New York Times (2012)]