Think of there being two actual resolutions at play now. One is the pixel resolution, and one is the logical or perceived resolution measures in “points”.
So your iMac has a pixel resolution of 5120 x 2880 pixels.
And a logical point resolution is 2560 x 1440.
It renders elements on screen the same physical size as a non retina 2560 x 1440 monitor but with four times the density of pixels.
So the user interface elements and text will be twice as sharp, as there’s now four pixels available in the space where there would normally be one pixel.