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 office 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 devil's advocate 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 devil's advocate; 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.