What is a stardate? How does it work?
In addition to being, as others have said, a way to communicate to the audience that this takes place in THE FUTURE TA-DAH! without actually nailing down a specific Gregorian calender year, stardates serve a handy function from the POV of the characters themselves:
The Federation is a union of worlds with many different calender systems. As such, it would need a uniform calender system that's universally applicable, and which also takes the effects of relativistic time dilation into account. Hence -- stardates! A Federation citizen from Alpha Centauri can say that such-sand-such happened no Stardate 50893.5 and fellow Federates from Vulcan, Berengaria, Peliar Zel, Sulamid, or Coridan can understand him.
As others have said, for most purposes, the audience won't much care. You can see how the stardates relate to Gregorian calender years
here. As you can see, they didn't really nail down a system for stardates in TOS or the TOS movies (although later films and episodes established that TOS took place between 2266 and 2269).
TNG/DS9/VOY-era Trek:
For TNG, they nailed down the following stardate and Gregorian calender system: Each season of TNG would correspond to one standard Earth year. The first two digits of a stardate would also correspond to a year, and the second digit would be the same as the season number for TNG. TNG Season One took place in 2364. This system was carried on even after TNG ended.
Therefore, we get a system whereby:
2364 = Stardates 41000 to 41999 = TNG Season 1
2365 = Stardates 42000 to 42999 = TNG Season 2
2366 = Stardates 43000 to 43999 = TNG Season 3
2367 = Stardates 44000 to 44999 = TNG Season 4
2368 = Stardates 45000 to 45999 = TNG Season 5
2369 = Stardates 46000 to 46999 = TNG Season 6 / DS9 Season 1
2370 = Stardates 47000 to 47999 = TNG Season 7 / DS9 Season 2
2371 = Stardates 48000 to 48999 = DS9 Season 3 / VOY Season 1 /
Star Trek: Generations
2372 = Stardates 49000 to 49999 = DS9 Season 4 / VOY Season 2
2373 = Stardates 50000 to 50999 = DS9 Season 5 / VOY Season 3 /
Star Trek: First Contact
2374 = Stardates 51000 to 51999 = DS9 Season 6 / VOY Season 4
2375 = Stardates 52000 to 52999 = DS9 Season 7 / VOY Season 5 /
Star Trek: Insurrection
2376 = Stardates 53000 to 53999 = VOY Season 6
2377 = Stardates 54000 to 54999 = VOY Season 7
2378 = Stardates 55000 to 55999 = (no TV episodes or films set that year)
2379 = Stardates 56000 to 56999 =
Star Trek: Nemesis (last TNG-era film or episode)