Restrict visibility, and up the monster's ranged damage
Since you said "resistance to ranged attacks," I thought you might mean damage resistance: you could simply do that, give it "Resistance to damage from sources other than melee attacks." But doing that will still make "kiting" it the best strategy, and practically resource free. Of course, you could just give it immunity to damage from sources other than melee attacks.
But I urge you not to.
Players running ranged characters deserve the chance to run their character any way they choose. So I think you made the right decision to avoid immunity to ranged damage.
I have two main suggestions:
I'd suggest you do the following:
- Give it blindsight, 120 foot radius
- Up its ranged damage (to about 1/3 of a single PC's total hit points) per round, and up its ranged distance to 120 feet
- Have it live deep underwater, so deep that it is in total darkness (perhaps its eyes are very sensitive, and it always retreats from light, regardless of the source).
Darkvision is limited
Many PCs will have darkvision, but few will have it further away than 60 feet (and almost none will have it further than 120 feet). By giving your monster such a large blindsight radius, you ensure that it can see PCs before they can see it.
If a PC tries to kite the enemy from even further away (say, with a longbow from 140 feet), and take disadvantage because they can't see the monstrosity, let them try. Describe the arrow vanishing into the darkness. And say nothing else. Now it's their turn again: what do they do? Now the PCs have to wonder. Did they hit it? Is it coming for them? Is it retreating? If they fire again, will it have moved? Pretty quickly, it will become apparent that this strategy has too many unknowns (if they keep trying it, give them three rounds of silent distant hits, then it's moved 15 feet away and out of range: but they don't know that. They could fire arrows for quite a while into empty water. And if they say "well, I just keep shooting", then after 20 rounds [which you can fast forward through] it suddenly comes into view from the side!).
Ranged attackers will also be restricted by the fact that ranged weapons don't function as well underwater (working only up to "short" range). Of course, a spellcaster could still whip cantrips from a considerable distance, but then they run into the visibility problems I mentioned above.
It gives as good as/better than it gets
Your starfish can return fire at faraway attackers who attempt to "kite" it while it is visible. And if a single character (like the Ranger) tries to do so alone, they will quickly realize the plan will drop them before they drop the monster.
In order to defeat this creature, they'll either need to get creative (perhaps casting dancing lights, or trying to lure it into a trap), or at least ensure that their entire party is doing damage to it at the same time. If you have a mix of ranged and close-range characters, everyone will get a chance to shine.
Gentle until provoked
To make this creature fun to fight, rather than a TPK machine, it is crucial that the starfish is "non-aggressive," like you said. PCs will be able to swim very close to it before attacking if they wish, and start combat with your melee characters up close and your ranged characters far away. The ability to start combat where they want will be essential: most players move at half speed underwater. Giving this creature such a large effective range, while also reducing your players' movement, ensures that if this creature can attack the PCs as they approach, it will decimate them.
If none of this sounds good to you: enjoy being sniped
Your creature design as it stands is interesting, but it absolutely cries out to be kited and sniped. And that's not necessarily a bad thing. There are a lot of ways to make such an encounter interesting. For example, what if while you're kiting the starfish, a much larger one rises from its burrowed hiding spot under the PCs (Mama's angry!). Or have the smell of blood attract sharks, who go after the PCs first. Or the starfish squeezes into a nearby cave, which twists and turns in such a way to stop PCs from hitting it from extreme distances.
But if you insist on having the creature stay in the open, have a slow speed, and a low effective range, then ranged attacks are simply the only reasonable approach for your PCs to take.