Screen resolution tells you how many pixels there are in the screen.
DPI, both vertical and horizontal, tells you how many of those pixels there are in an inch.
Together they tell you the physical dimensions of the screen.
Knowing the physical size of the screen you can make an informed choice about what size of text is necessary for something to be "readable".
So, for a 4K resolution on a 27inch monitor you would need a higher font size than you would a 1920x1080 resolution just to maintain the same level of readability.
Not all screen elements will be so directly tied to DPI, hence you see font size changes while other elements do not necessarily follow or respect DPI changes.
What parts of the system respect DPI depends on how the software was written and how it is all pieced together.
But, you can lie about the DPI. You can make the computer think the screen is far larger or smaller than it really is. In so doing you can change the size of text to what you want while still maintaining DPI-aware abilities and smart scaling of elements. In theory it is not just a change in font sizes, but of every DPI-aware element. The whole screen can change in unison.
Without DPI guiding how scrollbars, fonts, lines and other things are drawn in relation to each other you would have to resort to "brute force" scaling of elements. For 4k you could simply multiply the dimension of every element by 2, but it would look awful, and you might as well just have the lower resolution screen to begin with.
By using DPI aware elements you can have elements that are a percentage of an area and are drawn cleanly using true lines in the screen native resolution rather than drawn at a lower or higher resolution and then scaled arbitrarily by hardware or software.
That is what DPI gives you, intelligent scaling of screen elements without the brute force scaling.
It results in cleaner lines, better use of the real resolution, and overall more intelligent use of screen real estate.