This comment from /u/rosemary85 probably answers it best:
It is true that 300 Spartans led by Leonidas died fighting at Thermopylae. It's possible that it came to an end in the course of an assassination attempt on Xerxes. It is true that the following year there was another battle at Plataea, at which the Persian-led forces were trounced. At one point in the film there is a depiction of an othismos that probably comes closer to the reality of hoplite warfare than any other cinematic depiction ever. And that's pretty much it for historical accuracy.
The rest is largely based on propaganda that was effectively written by the Spartans after the event. This includes most or all of the catchy slogans ("Come and get them!" "Then we shall fight in the shade" etc.), and the idea that Leonidas planned the whole thing as a suicide mission. Ancient sources do attest these things, but they are intrinsically implausible: (a) it's all pretty transparently aimed at fluffing up Sparta for propaganda purposes (compare, for example, how Simonides was commissioned to compose a mini-epic about Plataea, almost certainly by the Spartans for political purposes: to emphasise their preeminent role in that battle, and to push the idea that that was the key battle of the Persian Wars, with the implication that they ought to get the leadership of the pan-Hellenic alliance that eventually became the Delian League); (b) a general with a death-wish is not a sane general; (c) plus, how would the writers have got access to this information? The whole point of the story is that all the potential informants died!
Then there's a bunch of things that the film just stays silent about: the fact that in reality there were plenty of Greeks fighting on the Persian side as well, and the fact that the Spartans were a small minority of the Greek army (yes, right to the end). Even by Herodotos' time this last fact was remembered, but usually ignored: Herodotos tells us that he knew the names of all 300 Spartans, but no hint that he was even interested in the names of any of the Thespiaeans or Thebans. There's Spartan propaganda for you!
Some of the characters are pure inventions: Dilios and Ephialtes are fictional (it was quislings from Trachis, just north-west of Thermopylae, that guided the Persians around the pass).
Then there are the intentional misrepresentations: in particular the bland equation of Persians = Iranians = blacks (Xerxes was not a giant, nor is he likely to have been any darker-skinned than modern Iranians are), and the casting of the priests who forbid Leonidas to go to war during the Carneia as disfigured monsters. These are basically avenues for the writers - well, really, I mean Frank Miller - to promulgate his agenda of racism, eugenics, and secularism.
hi! lots of info in these related posts...
How historically accurate is the film 300? (same post linked by /u/donnybear)
How accurate is 300 to real history?
How accurate is the movie 300?
A rather simple question about the Battle of Thermopylae...