It really depends on the game and the setting.
In something like D&D, magic items provide a hook to keep the players interested, since they never know what they'll find next. In some editions, the so-called treadmill of enhancement progression also serves to give the players something to look forward to - if you have a +2 greatsword, then you want to keep playing in the hopes of finding a +3 greatsword - similar to gaining a level, but without the convenient EXP countdown that takes all of the randomness out of it. Artifacts are also useful as quest goals, both in terms of MacGuffin and as side quests that help them complete the main quest.
In something like Shadowrun, magic items make more sense as a build option, which anyone can purchase with enough money. If it's possible to create a magic sword, then someone will do it, and it will be available for the right price. That's just what makes sense for how the world works. Magic items as a random lottery mechanic (to keep players interested) is not something that works terribly well in a world where everything is easily fungible.