Its because of 2 things really.
1: combat wise a fighter is better at everything they do. Even paladins are better. And some other classes can be as well depending on their subclass. What little unique spells they have are almost all tied to ranged combat. So if you want to play a melee ranger several other classes do it better then you do.
2: their unique features are very niche. And in tabletop often dont get used or are under utilized. Theyre essentially, all roleplay features.
Basicly, a player has to know upfront what the dm is going to do for an enviroment and enemy wise; or most of his features go to waste.
The features also only work in their favoured terrain. So say you are a forest ranger and end in a desert..... all your special features just stopped working.
Preferred enemy is a nice feature. But its very limited and ONLY works against that particular enemy. So you can play a campaign and never run into yohr preferred enemy

Tldr a Ranger is....fine if build as a ranged character. If you get to play in your preferred enviroment you are a superstar when it comes to roleplay. Survivaling with a Ranger is super easy. Without one its a pain in the ass if your dice rolls dont go well. If you are not in your preffered enciroment its just a subpar fighter. What little spellcasting a ranger has generally only benefits them. And only benefits ranged builds.
Hope thats helpfull
