In RTS games, units are usually classified in different categories that represent their strengths and weaknesses, different weapons, abilities, etc. Edain, BFME and many RTS are based on Medieval warfare, so the units follow the same classification. Each unit type will be strong/weak against others, like a complex rock-paper-scissors game. This allows for strategic gameplay, and forces each player to adapt to the enemy army, as well as rewarding thinking and skill by using the most suitable troops in each situation.
Infantry normally constitutes the main part of your army, formed by all soldiers that fight on foot. They are classified according to their main weapon:
Swordsmen are the basic unit in the army: they are usually cheap, deal average damage to buildings and are strong in melee combat. However, swordsmen are very easily killed by cavalry (they receive a lot of trample damage and also lose in melee against cavalry), and also are vulnerable to archer fire unless they are close enough to engage in melee fight. Use swordsmen as the bulk of your army, as they are the most cost-efficient unit in melee combat, but avoid using them without support from other units. Swordsmen are good against pikemen, so try to focus those rather than the enemy swords (can be difficult in some fights). If your enemy overproduces pikes, get more swords and fights will always be in your favour.
Pikemen are infantry that carry pikes or spears, and their function is to defend swordsman from cavalry. Pikes are usually slightly more expensive than swordsmen and less efficient in melee combat (will die to swordsmen in 1v1 situations and also receive more damage from archers), so pike-overproduction renders your army weaker and less cost-efficient (as you spend more money on producing pikes, your performance in melee engagements worsens). As the main function of pikes is defending from cav (very important: pikemen are not meant to kill cav, their main purpose is defending from cav), produce them BEFORE your enemy gets cavalry, and in the just numbers: in early game, one pike battalion per army (supposing you have more than one) will be enough to defend from the occasional cavalry battalion, but as the game progresses, try to have pikes in a 1:2 ratio to enemy cav, if not more. Take into account that cav is very mobile, so if you have a main army with 3 pike units against 4 enemy cav units, your main army will be safe, but perhaps a secondary harassing force comprising of one pike and one swords may die to the cav.
Pike positioning is also very important: try to have most of your units covered by pikes at all times, and at the same time, avoid pikes getting in melee fight as much as possible (swordsman will do it better), as losing them inefficiently in melee fights will leave your army unprotected from cavalry. Also, if you see enemy cavalry charging, try to put the pikes in front to absorb the impact and deal the most amount of damage to the charging cavalry.
Archers are ranged infantry units whose primary function is dealing damage at range. They are good against infantry (especially pikemen), and even cavalry if protected by pikemen. Archers should avoid being caught in melee fights at all costs, because will die easily. Also, they die very quickly to enemy cavalry. Archers (especially when you have some speed advantage) are also very good at hit and run tactics, harassing enemy infantry and slowly giving you an advantage. In addition to that, archers can easily target enemy units, so they are ideal for taking enemy pikemen at range, thus giving free roam to your cavalry to destroy the rest of the enemy army.
Cavalry is the main support unit of any army, formed by soldiers who ride horses. Cavalry can trample (that is, deal damage by throwing units to the ground), and that makes it ideal to quickly kill enemy infantry. Cavalry is also good at destroying buildings and chasing down fleeing enemy units (especially heroes). The counterbalance is that cavalry dies very quickly to enemy pikes. To use cavalry well, it should be constantly harassing or assisting in important fights all over the map, making use of their speed advantage and building damage potential. Take into account that well-microed cav will almost never die to pikes, as it is faster. If your enemy sends some pikes to stop you from harassing, just go harass at other place, and run rings around the pikes while dealing damage to their buildings. Of course, try to avoid being surrounded and/or accidentally trampling enemy pikes.
Monsters follow the same principles as cav, usually dealing less trample damage but melee knockback damage. Also, monsters are usually more vulnerable to archers.
Ranged cavalry is a special unit that few factions posses and has the speed advantage of cavalry, coupled with the targeting capabilities of archers. Ranged cav should pick and destroy enemy pikes, using hit-and-run tactics. Don't forget that they can also trample lone swords or archers. Their weakness is melee combat and archers; they die easily when attacked by enemy ranged units.
Nazgûl on fellbeasts and Eagles are flying units, which cannot be attacked except by archers and other ranged units. They are very fast and deal aoe damage (with knockback), making them good against infantry (specially if clumped), cavalry, and heroes (they can chase them, and nothing can stop/slow them). In addition to the aoe damage, they take one unit from the ground and throw it, instantly killing it, regardless of the health or armor of that unit (this doesn't apply to heroes), so they are specially strong vs elite/heroic units.
Heroes are special, known characters from Tolkien's world that have unique abilities and have superior stats to units. They are strong in any form of combat, although vulnerable if isolated (they receive lots of flanking damage). They can sometimes follow the same strengths/weaknesses as units (for example, mounted heroes will die easily to pikes), and there are some roles that define what the hero is good at. For example, some heroes have abilities and stats specialising in killing other heroes (hero killers), while others will excel at destroying buildings or killing large amounts of enemy units. However, those roles don't play such an important part as the unit ones. A hero killer will likely die to two other heroes (even if they are not also hero killers), and most heroes are good against units.
Siege take an important role in destroying enemy buildings more quickly and efficiently than units. However, siege is expensive and very vulnerable to melee enemies, so make sure to protect it at all times.
Some units don't follow the main classification, such as Cirith Ungol Halberdiers (which are pikes that are also good against swords), or Ents (slow monsters that also work as siege). Most of them have those particular traits explained in their description and allow for extra diversity in gameplay. Also, some units have abilities that allow them to have extra functions (for example, Wargs and Imladris cavalry have speed boosts that allow them to chase other cav, turning them into "anti-cav" cavalry).
Used properly the counter system will allow you to play well and make the most of every unit in your army. The player that is one step ahead in the counter play (so, the player that gets cavalry before, archers before, etc) will have an advantage over the enemy and will force him to adapt. Also, having different units in your army, each specialising in a different task, will make it more cost-efficient. As an example, take a look at this game played by Goodfella and WCP, Gondor vs Imladris. Goodfella avoids thoughtless spam of infantry, and uses a combination of different units to defeat his opponent.
In this other game, Antares (aka Mogat) uses the exact same principle to counter his enemy's play:
In Edain, units (regardless of their weapon) are further classified into basic, elite and heroic. These tiers represent a significant increase in stats, such as health, damage etc. This means that an elite pike will usually win vs a basic sword, and heroic archers won't be dead instantly from cavalry charges. Still, the rules of the counter system still apply.