It’s all about scaling. Historically, the Mac targeted 72 ppi — in the old days that was used to ensure WYSIWYG. But in more modern times we have settled somewhere closer to 90-110 ppi.
A typically nice resolution for ~100ppi on a 27" is 2560x1440. And with 5K, i.e. 5120x2880 you can get exactly that with 2x scaling (“Retina”). So you render 218 ppi with exact 2:1 scaling. You get a nice sharp image with a high resolution since it looks like 109 ppi to you.
Contrast that with what I get on my 27" 4K. There I have 3840x2160. If I choose the same crisp 2:1 scaling I end up running effectively 1920x1080 which renders only 86 ppi. That’s too low so everything looks comically big and I don’t get to see enough screen real estate in spite of having a big 27" panel on my desk. So what I instead end up having to do is tell macOS to display for an effective 2560x1440 (same old school 27" res) which then renders 109 ppi so all good. Except nope. That scaling forces macOS to render everything to the closest pixel because instead of using just 4 pixels to draw 1 (2x scaling) I’m now using 1.5x scaling which means 1.5 pixels x 1.5 pixels to draw that same single pixel. But since you cannot draw to 2.25 pixels to show 1, macOS has to dither and the result of that, even though I have no serious complaints myself, is just never as crisp as if it could render to integer multiples of the displayed resolution.
The bottom line is: if you go 4K on a 27" you can get either a crisp image (low res) or a high res image (dithered) but not both at the same time.
If OTOH you get 5K for your 27", you can have it all at once. IMHO 5K is therefore clearly the way to go. The only problem with that is that 5K monitors are so darn expensive compared to 4K. That’s because there is much greater demand for 4K panels (TVs) than 5K (computer nerds) and hence the latter are still substantially more expensive. There’s a factor ~5 in cost between my 27" 4K Dell and a reasonably configured Apple Studio Display.