I've stumbled into a conundrum in my 5e game. I think solving this question will help me.
What is meant by the rarity of the magic items if all magic items are rare? Does it mean that you can find more than one +1 longsword?
Role-playing Games Stack Exchange is a question and answer site for gamemasters and players of tabletop, paper-and-pencil role-playing games. It only takes a minute to sign up.Sign up to join this community
This is explained in the Rarity section of Magic Items on page 135 of the DMG:
Common magic items, such as a potion of healing, are the most plentiful. Some legendary items, such as the Apparatus of Kwalish, are unique. [...] Rarity provides a rough measure of an item's power relative to other magic items. Each rarity corresponds to character level, as shown in the Magic Item Rarity table. A character doesn't typically find a rare magic item, for example, until around 5th level. [...] If your campaign allows for trade in magic items, rarity can also help you set prices for them.
Aside from being a rough measure of power, rarity, as somewhat stated above and by its very name, also provides a guideline for frequently characters might find a certain type of magic item.
A legendary magic item is far more powerful and likely to be far more scarce than an common or uncommon magic item. Characters might find multiple Cloaks of Protection (uncommon), for example, throughout their adventures but would probably only ever find one Robe of the Archmagi.
Depending on the type of game your DM runs, obtaining magic items may be a rare occurrence but that still doesn't necessarily mean that all magic items are rare or that there's only ever only one of a magic item in existence.
You asked: "Does it mean that you can find more than one +1 longsword?" which does not appear to be addressed in the other answers.
By the book, yes, you can find more than one +1 longsword. There is not just one +1 longsword.
Very few items are unique. "Some legendary items . . . are unique." (DMG p135). "An artifact is a unique magic item" (DMG 219).
On the other hand, the DMG considers a +1 weapon to be merely uncommon, and refers to +1 longswords almost generically: "for example, if a hobgoblin tribe has a +1 longsword" (p133), "a generic magic item, such as a +1 longsword" (p141) and also says that a 3rd level character could craft a +1 weapon (pp128-9).
So, while rated uncommon, it might be very likely to come across multiple +1 longswords in an adventuring career, or for several characters in a party to have one.
Not all magic items are rare. The rarity of an item, as written in the DMG, determines how hard it is to find such an object. A potion of healing, for example is a magic item of a common rarity, which means a simple encounter for a level 1 group could have this in its loot. On the other hand some groups have to wait for 15 to 20 levels to get a legendary item, like the Archmagi Robe.
You can also have a look at the Treasure Tables, starting arround page 235 in the DMG, to get a feeling on what encounter a party has to beat to get a certain item.
If your question was about magic items which have multiple raryties like the Instrument of the Bards or a Weapon +X, then that just means there are 'better' versions of the same item, that are harder to find. E.g. a longsword +1 can be found relatively early in a campaign, while a longsword +3 is more like an endgame weapon, since it has the best bonus one can achieve due to a weapon.