How pixel density is calculated
Pixels per inch is the diagonal resolution divided by the diagonal screen size. Find the diagonal in pixels with the Pythagorean theorem, then divide by the inches the manufacturer advertises. Worked example with the defaults: a 27-inch 1440p monitor is 2560 x 1440, so the diagonal is the square root of 2560 squared plus 1440 squared, which is 2937.2 pixels. Divide by 27 and you get 108.8 PPI. Dot pitch, the center-to-center distance between pixels, is 25.4 divided by the PPI, here 0.2335 mm.
Once you know the PPI you also know the physical dimensions, because width in inches is horizontal pixels divided by PPI. The same 27-inch panel is 2560 / 108.8 = 23.5 inches wide and 13.2 inches tall. That is worth checking before buying a monitor, since two screens with the same diagonal but different aspect ratios occupy very different amounts of desk.
What counts as a good PPI
It depends entirely on viewing distance. Phones are held 10 to 14 inches away and need 400 PPI or more; an iPhone runs about 460. Laptops at 20 inches look excellent from around 200 PPI, which is where Apple's 224 PPI panels sit. Desktop monitors at 24 to 30 inches away are comfortable from about 110 PPI upward: a 27-inch 1440p display gives 109 PPI, a 24-inch 1080p display 92 PPI, and a 27-inch 4K display 163 PPI. Televisions viewed from 8 feet need very little: a 55-inch 4K set has just 80 PPI and still looks flawless.
The threshold where pixels become invisible follows a simple rule. Human vision with 20/20 acuity resolves about one arcminute, so the distance in inches at which pixels disappear is roughly 3438 divided by the PPI. For 460 PPI that is 7.5 inches, closer than anyone holds a phone. For 109 PPI it is 31 inches, about arm's length at a desk. For an 80 PPI television it is 43 inches, just over three and a half feet, far closer than most people sit.
PPI, DPI and interface scaling
PPI describes a screen; DPI describes a printer, where dots of ink are laid down at 300 to 1200 per inch. Photo files carry a DPI tag, but that number only matters when printing. A 3000 x 2000 photo prints at 10 x 6.7 inches at 300 DPI or at 20 x 13.3 inches at 150 DPI; the pixels never change, only the intended size. For screen use, the tag is ignored entirely and the pixel count is all that matters.
High-density screens would make text unreadably small if drawn at one interface point per pixel, so operating systems scale. macOS renders many panels at exactly 2x, so a 220 PPI laptop shows interface elements the size they would be at 110 PPI but with four times the detail. Windows uses percentage scaling, typically 125, 150 or 200 percent. This is why a 27-inch 4K monitor at 163 PPI is usually run at 150 percent scaling: you get the sharpness of 163 PPI with the working space of roughly 109 PPI.