Contrary to popular belief, very few fatal injuries result in instant death. As long as you haven't been decapitated, shot in the head, or blown up, your body will take at least two minutes to fully shut down. So long as your throat is relatively intact and you can get breath enough to make sound, this gives you a chance to belt out a few parting words to your comrades or the enemy that felled you. Of course, this doesn't really work in real life, since few people (except for those expecting to die) have good last words prepared, or the energy or wherewithal to say anything as they go into shock. Ah, but this is fiction...
Fictional characters who aren't killed instantly will usually have something to say. Some can pull off the Final Speech, able to utter page after profound page in their dying moments. These are usually delivered with the calm gravitas of someone who knows the end is near. In contrast, Famous Last Words are brief and often poignant: the statement said by a character who hasn't quite accepted that he's dying. These can actually be very character-defining, to the point that they represent the very climax of that character's development leaving a lasting impression on the other characters and the fans.
This is difficult to write despite being just a few words. Misuse it and it can come off as cheesy. Done perfectly and it can even garner the respect of a fan that hated the character. An affectionate subversion is that a character utters what he expects will be his Famous Last Words — but survives after all.
Compare Sedgwick Speech, where a character gets killed directly after his speech or one-liner, usually in an ironic fashion. See also "Facing the Bullets" One-Liner where a character says a one-liner before knowingly facing death and Dying Curse when these words are a curse. See also Dying Declaration of Love and Dying Declaration Of Hate. Often a Tear Jerker.
Some supposed Real Life final last words are fictional, and were possibly concocted for ulterior motives. At the time of his death, it was widely reported in newspapers that Lou Costello's last words were "I think I'll be more comfortable", said to the nurse who was preparing to help him turn over in bed. Within months the legend arose that he died in the presence of a group of beloved friends and that his last words were "that was the best ice-cream soda I ever tasted". Whether his friends were embarrassed that he died virtually alone or whether someone meant to imply that Costello died because he was fat (he had a chronic heart valve infection) nobody knows, but the legend can be found in almost every book of famous last words.
Massive Spoilers Within, so don't go further if you don't want them. The Other Wiki has an extensivelist of its own.
"Yeah, but this is no joke." Andy, a member of Buddy Lewis and the Cats
"Do you guys smell that? It's something... electrical..." Nick, a member of Buddy Lewis and the Cats
"I can't pull it up! C'mon Buddy!" The pilot for Buddy Lewis and the Cats
"No! You mustn't interrupt the experiment!" Dr. Victor Belmont
"I don't care!" Thug's Brother
"What is that?" Thug
"It's beautiful. AAAAAHHHHH!" The Fake Agent Garfield
The Bible has Jesus's eponymous 7 Last Words before He died on the cross for mankind's sins just before He rises from the dead 3 days later:
Father, forgive them for they know not what they do. Today thou shalt be with me in paradise. Woman, behold thy son, behold thy mother. My God, my God. Why has thou forsaken me? I thirst. It is finished. Father, into thy hands, I commend my spirit.
"The last time I saw you, you were heading into Rath. We fought, I remember. I'm sorry. We also said good-bye. I didn't think that good-bye would be our last. I was wrong about everything. Everything. Good-bye, my angel." Barrin, Master Wizard
"Here sits one who maybe more than any other, can stop their spread. And he is my friend. I will not let him fall like a dog to this sickness. You cannot ask me to let that happen." Venser, the Sojourner
"I don't have time to die, I'm too busy!" — Goge Vandire, Ecclesiarch and Master of the Administratum ca. M36, architect of the Age of Apostasy, to the captain of his Praetorian Guard immediately before she decapitated him
"See? That wasn't so scary. A cup of coffee, please? Thank you. AAARRGH!!" — Brendan Fraser, in the Orlando version of the ride.
A long series of jokes:
Tarzan's last words: "Who greased the liana!?"
The electrician's last words: "Yes, I'm sure I switched the main breaker."
The cardinal's last words: "Matches? I thought you had them."
The general's last words: "Watch where you're pointing that bow and arrow, you'll have someone's eye out in a minute."
The biologist's last words: "Only experts can tell the difference between the harmless legless lizard that I'm holding in my hands and the similar-looking horned viper..."
The classic redneck's last words: "Hey y'all, watch this!"
Another version is, "Hold muh beer n' watch this!"
"Watch this!" is Truth in Television. There exists a book of all the deaths that have occurred at the Grand Canyon, and nearly an entire section of it is stories that start, "X had been drinking," and move on to, "X said, 'Hey, watch this!' and tumbled into the canyon."
Historical: Jorge Chavez, a Franco-Peruvian who was the first man to fly over the Alps Mountains, suffered mortal injuries while trying to land on that flight. His last words: "Arriba — siempre arriba." "Higher — ever higher." This phrase is the motto of the Peruvian Air Force.