Our main source for the events at Thermopylae is the account given by Herodotus of Halicarnassus, which was written in the 440s or 430s BC, some forty or fifty years after the battle was fought. All of the stuff you see in 300 ultimately goes back to his account or later dramatisations of it. While the story was already subject to distortion in Herodotus' time, we have no reason to assume he was just making stuff up; his audience (including the peoples who were supposedly involved in the battle) would probably not have let him get away with outright invention.
In addition, he is not the only source we have on the battle, which increases the likelihood that the event was historical. The most contemporary source is actually the epigram composed by the poet Simonides to be put on the monument placed at Thermopylae. This is the famous line, variously translated, of "Go and tell the Spartans, stranger passing by, that here, obedient to their laws, dead we lie". It dates to shortly after the final defeat of Xerxes' invasion force in 479 BC.
There is also the account given by Diodorus of Sicily. This is a much later source (1st century BC), but it preserves information from several historical accounts that are now lost; wherever it does not agree with Herodotus, we may assume that Diodorus is drawing on an alternative tradition. As it happens, his account of the battle of Thermopylae does differ from that of Herodotus in a couple of ways, again reinforcing the notion that this event really happened - it was being remembered differently by different people at different times.
The simple answer is that the Greek historian Herodotus wrote an account of the battle. When he was writing the battle was still in living memory. The veracity of the details of his account are questionable, eg the overestimation of the size of the Persian army, and the specifics of conversations and so on, but there is nothing to suggest that the battle itself was invented. Does that help?