Legendary Pokemon serve several purposes in the games.
Firstly in the games they give the player a goal aside from defeating the Elite 4. At least one legendary Pokemon is usually an important part in the plot of the games, and can be caught through regular play. In the Gen I games, there was no plot-important legendary, but 4 could still be caught through regular play anyway.
Secondly, they add to the mythos of the Pokemon universe. The idea that Pokemon created the continents, the universe, other Pokemon, etc. (you get the idea) allows legends and stuff to add more depth to the Pokemon world.
Thirdly, its not like their presence really makes the game unbalanced, for several reasons. Many people (myself included) refuse to use legendaries in-game to stop them from steamrolling everything. And competitively they invented the Uber Tier to act as a safeguard for that.
Fourthly, they are hardly unbeatable (except for Mewtwo in Generation I - that is truly the most overpowered Pokemon ever).
The not only add interest in terms of mythology, they also add interest in terms of battle Many have unique moves, abilities, or other things that make them different to other Pokemon in battle. Mew can learn every TM, and is the only Pokemon aside from Ditto to get Transform. Shaymin learns Seed Flare, Victini has Victory Star, and Meloetta can change its form in the middle of battle, the type of which is almost a perfect counter to its first form's weaknesses.
As for fairness to regular Pokemon -do you really want every Pokemon to be like Rattata? There are some Pokemon that are stronger, and some that are weaker. It adds interest to the game. If you want a challenge, try to beat the game using only Pokemon with a BST lower than 420 (Raticate has 413). Yes, most legendaries have high stats, but like I said, that just adds interest, and is only really a problem if you make it one.
One final point, competitively some legendaries aren't actually that good. Mew, Zapdos, and Victini are in the UU tier, Mesprit, Uxie, and Moltres are all RU, and Regice, Regigigas, and Regirock are NU.