When Éomer first meets the three characters, his éored surrounds them and points spears. When Gimli asks him what his name is, Éomer racially abuses him and threatens to kill him.
What are the reasons behind his reaction?
He has a number of problems. Sauron is known to be gathering an army in Mordor to launch an assault on Minas Tirith, which nobody reasonably expects to be able to survive for more than a short while. Meanwhile Saruman is known (from Gandalf) to be a traitor, and is building/breeding his own army of Uruk-Hai who regularly raid Rohan. To make matters worse, you also have Saruman's new pet/spy Grima Wormtongue whispering poison into the ear of the King of Rohan, essentially robbing him of hope and life.
My memory of Middle Earth geography isn't great, but I believe that Gondor and Rohan are neighbouring lands. That means that, once Gondor falls (and they have no reason to believe that it won't), Rohan is stuck between two armies. They're understandably afraid of what the future will bring, and as a result, extremely wary of outsiders.
Now Aragorn, Legolas - an Elf, who the people of Rohan only know from stories and myths, most of which don't cast them in a favourable light, having had no contact with them personally - and Gimli come wandering into the lands of Rohan in pursuit of the two hobbits. They are, for all purposes, trespassing in Rohan. When confronted by Eomer, who is charged with ensuring the safety of Rohan and upholding its laws, rather than simply answering his questions and giving their names, Gimli responds with questions of his own.
He's not "being a dick", he's simply doing his job: Confronting unknown trespassers within the lands he's sworn to protect, discovering their identities and seeing if they're a threat to Rohan. For all he knows at that point they could well be allied with Saruman and in league with the band of Orcs he'd recently slain.
The events as depicted in the film which have occurred (essentially) directly before their meeting has Éomer justifiably suspicious and defensive.
"Saruman has poisoned the mind of the king and claimed lordship over this land. My company are those loyal to Rohan. And for that, we are banished. The White Wizard is cunning. He walks here and there they say, as an old man, hooded and cloaked. And everywhere his spies slip past our nets."
All the answers above are correct, the peoples of Middle Earth are divided at this time. However, I believe Eomer spoke the way he did because Gimli was being rude (knowing the character, probably on purpose). Courtesy, especially in the days and cultures upon which LOTR is based, dictates that the home team (so to speak) has the right to demand ID's. Names had power, and the first person who gives their name should be the one in the visitor/weakest position. When Gimli demands Eomer's name first before he gives his own, he is saying he outranks Eomer even before he knows who he is. Thus, he is purposely being rude. Of course Eomer responded as an offended party, which he was. It was a moment Tolkien took to show the way the races were divided, how Gimli and Legolas were becoming friends (counter to their racial prejudices) and then showed how Aragorn could unite them, which he did.
There are two basic answers, both different but true.
1) As Eomer makes clear in the book and the movie, the times are strange and it's difficult to know whom to trust, especially in light of Saruman's betrayal. Here are three people trespassing in the land, it wasn't a situation (in Eomer's estimation) calling for courtesy. Instead, he wanted answers.
2) A more overarching answer is that a major theme of LOTR is that confronting and defeating real evil requires solidarity. No one person or race or land can do it on their own. This is on display when there is a bit of posturing by all the races/people present at the council about the Ring at Rivendell. The amazing thing here is that a person from the "least" of all races, the Hobbits, is willing to risk all and bear the ring to Mordor. It is Frodo's sacrifice that galvanizes a "fellowship" consisting of all the races: Hobbits, Elves, Humans, Dwarves, and even a Wizard (whom Tolkien readers know is really a heavenly representative).
So instances of "racism" or "abuse" (to hearken back to the OP) are present precisely to remind readers that the races are splintered in the narrative world of LOTR, and this lack of unity is one of the primary threats to their chances of overcoming evil.
Although this concept is pervasive in LOTR, I think a great illustration is when Frodo escapes from Boromir and ends up in the Seat of Seeing. When this happens, he is able to see miles and miles around middle earth, and he sees each region fighting what basically appears to be a losing cause against the armies of evil. Middle Earth is divided and thus falling.
I'd like to add that Rohan and the Dwarfs didn't get on after King Fram was slain by Dwarves for insulting them when they demanded some Jewels from the hoard of Scatha the Worm.
Of his son, Fram, they tell that he slew Scatha, the great dragon of Ered Mithrin, and the land had peace from the long- worms afterwards. Thus Fram won great wealth, but was at feud with the Dwarves, who claimed the hoard of Scatha. Fram would not yield them a penny, and sent to them instead the teeth of Scatha made into a necklace, saying: “Jewels such as these you will not match in your treasuries, for they are hard to come by.” Some say that the Dwarves slew Fram for this insult. There was no great love between Éothéod and the Dwarves.
Ref: Lord of the Rings Apendixes
As the others have suggested, he has reason to be paranoid of strangers in an unexpected part of the country. However, in the book it goes down differently. When Aragorn identifies himself, rather than continuing to accuse the group of spying, Eomer falls all over himself to show him respect, as the rightful heir to the throne of Gondor, calling him "lord".