A city is a positive feedback loop in space.
Why locate anywhere but to be near something or far from something? Cities offer opportunities to be near lots of things (people), and as cities exist, those things must be of value to the people who locate there. By locating, people add to the "stuff" others can reach.
Accessibility is a measure of nearness to things (people), e.g. how much stuff you can reach in x minutes time. Which stuff matters and how much time is acceptable depend on individual preferences, but these can be measured and observed. An area with higher density enables you to reach more stuff in less time because it is physically closer, even if the network is slower (you can move less distance per unit time), provided the density increases at a rate faster than slowness increases.
Some cities are physically constrained, notably San Francisco (a peninsula) and Manhattan and most of New York (islands). In fact, the five densest cities in the US (New York, San Francisco, Los Angeles, Honolulu, and Chicago) all have some significant physical constraints (island, peninsula/bay, mountains/ocean, island/mountains, lake) hemming them in. Not surprisingly, these are among the most expensive cities in which to live. This indicates that the location is especially valuable, because of the accessibility benefits it provides.
Perhaps it is the constraint itself which creates value. Because of the constraint, more people and firms are bidding for scarce space (since the non-scarce non-central available space has a much higher transportation cost (across the bay, off the island, in more distant suburbs) driving up rents. As a consequence, developers build at higher density in the core city, increasing accessibility. Because of the higher density, there is higher accessibility, creating value for residents and businesses, leading to even higher rents. Location has positive spillovers.
A city is a positive feedback loop in space. Spatial constraints accelerate the loop.