Rangers are the sniping and sneaky experts of the Eldar forces in Warhammer 40k. They are exiles - either self-imposed or forced - from their craftworlds because they can't stand the boring Paths of the Eldar and want to see the galaxy, explore it a bit and have a life. While this may seem quite sensible and you may sympathize with them, the downside is without the mental constraints of the Paths, the Eldar exiles are free to be all nutty like their ancestors were when Slaanesh was born and nommed them, so the drawback of possibly being daemon food may make you think twice before picking this kind of life.
Anyway, Rangers are still loyal to their craftworlds and can be called upon to assist in times of need. They do this by using Ranger Long Rifles and taking out various key threats before they can reach the Eldar on the battlefield. Since they come in squads, the prospect of a bunch of invisible (they have powerful camo cloaks) Eldar snipers is not a pleasant prospect.
They are often used as a character class if the Eldar are included in a 40k RPG as they can make interesting characters with their wide spread travels allowing them to build up a range of skills, abilities, and meet various potential allies and foes.
In Dawn of War, they were annoying for their invisibility and sniping fire, especially since they also took away morale like no one's business. Unless you had a hero or a sensor it was very difficult to counter them....grrr unless you got your boys throwing grenades in their general direction. Take that you tree hugging bastards...
On the Tabletop
8th edition Rangers are arguably the most
defensive best troop choice Craftworlders can field, and are the second cheapest to boot (but who in their right mind wants storm guardians anyway?). With an innate -1 to hit modifier (which can be stacked with all the other modifiers for a maximum of a -4 to-hit) on top of a 3+ save when in cover, Rangers will not budge from any but the luckiest of ranged firepower (unless, of course, Dark Reapers are the ones shooting at them). Any army built on ranged firepower (like the T'au) will simply not be able to budge them. Additionally, Rangers fill an incredibly useful niche as your dedicated sniper unit and are able to use their above-average range to target and pick off weaker characters like Commissars, Warlocks, or Painboyz.
They do have their downsides, however. Those snipers are single-shot only at S4 and no AP, meaning they'll struggle to punch through MEQ targets and they'll barely put a dent in larger hordes. Additionally, Rangers are useless in melee and will quickly wither if someone pokes them a bit too aggressively with a stick. Additionally, Rangers are one of the precious few Craftworld infantry options who cannot advance and shoot their main weapons at all and even suffer the standard hit penalty for moving and shooting due to their rifles being classified as "heavy". They cannot really move and remain particularly threatening. All in all, they are still fantastic troop choices (particularly in Alaitoc lists, which offer additional bonuses to them in particular) that make excellent mid-to-backline objective holders and can be strategically deployed to help influence or punish enemy character placements.
9th edition has toned down Rangers' incredible defensive notoriety. They no longer have an innate -1 to-hit modifier (and indeed, they can only ever max out at -1 to-hit due to the new rules regarding hit/wound modifiers). This, coupled with their rather high point cost per model, makes them far less suited as a primary troop choice over Dire Avengers (who are probably the only Craftworld troop choice worth taking at this time). They still have a decent role as minor character hunters and, with support, can still become surprisingly difficult to clear off objectives.