The Einherjar are a group of elite warriors that serve as the main army of Asgard, and the main warrior-class of the Asgardian society. Einherjar warriors are personally trained by the ruler of Asgard and are tasked with protecting Asgard and quelling conflicts within the Nine Realms. During times without war, the Einherjar mostly serve as palace guards, notably serving as guards for Odin's Vault.
As the kingdom of Asgard grew in influence within the Nine Realms, it took on the role of keeping the peace between realms; thus the Einherjar were further tasked with policing the Nine Realms, preventing any realm from threatening any other realm's natural way of life.
First Dark Elf Conflict
Eons ago, during a cosmic event known as the Convergence, the Dark Elves, led by Malekith, attempted to destroy the universe using a weapon known as the Aether in a bid to return the universe to its original state of darkness. However, they were met with resistance by the armies of the Einherjar, lead by the then-current All Father, Bor.
The two sides engaged in a prolonged conflict with the Einherjar fighting the armies of the Dark Elves, including their empowered "Kursed" warriors. The Asgardian army eventually stopped Malekith, stealing the Aether from him using the Bifrost. However, a majority of the remaining Einherjar died as Malekith sacrificed his fleet of war ships, dropping them from the sky onto the warriors on the battlefield below.
Over time, Asgard rebuilt the forces of the Einherjar, who served in many more conflicts in other realms over the millennia before leadership was passed from Bor to his son, Odin, the current All Father of Asgard.
In 965 A.D. an army of Frost Giants from the realm Jotunheim invaded Tønsberg, Norway, in an attempt to subjugate Midgard (Earth) and plunge it into a new ice age using the Casket of Ancient Winters. However, they were opposed by Odin and an amassed army of Einherjar warriors, who, after a pitched war, drove the Frost Giants back into the heart of Jotunheim and took the Casket, forcing the Frost Giants into a peace agreement.
After a number of schemes set forth by Loki resulted in the destruction of the Bifrost Bridge, the realm of Asgard was isolated from the rest of the Nine Realms. Without Asgard and the Einherjar to maintain peace within the Nine Realms, the balance of power began to shift and many conflicts began to arise between various realms. Taking advantage of this conflict, a group known as the Marauders arose, attacking and looting various settlements in each realm, one by one. 
Later, after Thor traveled to Midgard to stop Loki and bring him back to Asgard, Thor also returned with the Tesseract, which Heimdall was able to use to restore the Bifrost. With the Bifrost repaired, Odin dispersed the armies of the Einherjar to the different realms in order to restore peace to the Nine Realms. The Einherjar subsequently fought alongside Sif, the Warriors Three, and Thor to quell the conflicts in various realms, most notably engaging in a prolonged conflict with the Marauders in the realm of Vanaheim. 
Second Dark Elf Conflict
When Algrim led a prison break from the Asgardian Dungeons, the Einherjar responded and were assisted by Fandral and Volstagg in battling the escapees who would not comply with Thor's order to surrender.After Frigga's funeral, Thor led the Aether-carrying Jane Foster away from Asgard to the Dark World in order to protect his home from Malekith's destructive search. This was in defiance of Odin's isolation decree. Odin had Tyr lead the Einherjar in a search for Foster and the Einherjar fought Volstagg, Sif and Fandral who were protecting her until Thor and Loki could affect her escape.
Einherjar soldiers are prestigious warriors whose uniform consist of ornate protective armor including: a chestplate with a high neck guard or collar, shoulder guards, gauntlets, boots, and other armor plating including a distinctive, ornate helmet. Their armor is also complemented by a fabric cape.
The Einherjar carry a small variety of weapons. Most commonly they use spears, some of which are double-tipped, for fighting enemies and keeping them at a distance and a short sword for close range combat. Additionally the Einherjar often carry an ornate, gold colored shield to provide protection against enemy attacks and can provide a small amount of protection against energy based weapons.
- In Norse mythology, the Einherjar are warriors that have died in battle and are brought to Valhalla by Valkyries to prepare for the events of Ragnarök.