A devil's advocate is someone who argues against an idea, position, or cause for the sake of argument, rather than out of actual opposition. While a devil's advocate can simply play a contrary role, someone who argues against an idea can also stimulate discussion which can identify weak points in an argument which need to be addressed. Therefore, one could consider this approach incredibly useful, albeit stressful for someone advocating alone against an accepted idea in a group.
The term is derived from a tradition in the Roman Catholic Church, in which someone would act as an advocate for the devil, arguing against the canonization of someone as a saint. The devil's advocate was an official position in the Church between 1587 CE and 1983 CE, and he was known as advocatus diaboli, which literally means "the devil's advocate." The person in this position was expected to come up with reasons why someone should not be canonized as a saint, to ensure that the canonization was undertaken in good faith and that the candidate truly was a saint.
In casual conversation, a person playing this role can seem extremely annoying, especially in a group which is generally in agreement on a topic, and even more so when it is clear that the person is arguing just to be contrary. In situations like this it can be helpful to remember the historical role of the position; rather than reacting with irritation, it can be interesting to actually discuss the issue with someone taking a contrary position.
In a more serious context, like that of a group of people making a major business or foreign policy decision, the devil's advocate is a crucial person in the group. Groups tend to enter a state of mind called "groupthink," in which members of the group make poor decisions because they want to maintain their collective cohesiveness. Groupthink is marked by things like self-censorship and the idea that everyone in the group agrees when this is not, in fact, the case. A devil's advocate can help to test a concept, ensuring that it really is sound.
Many people also use the term to excuse themselves before making a contradictory or potentially offensive statement, often saying something like "not to play the devil's advocate, but ..." This measure is often undertaken out of a desire to keep discussions calm and rational, as many people react unfavorably when their ideas are challenged. Don't be afraid to assume this role in a group, or even with yourself; by doing so, you can promote a probing of ideas, opinions, concepts, and positions to test their soundness. It also prepares you for arguing with someone who is genuinely opposed to the issue.