Cities provide more services, like museums and transit; and also tend to have wealthier tax bases (because of positive externalities cities create), meaning they can spend more and often do so. Though the additional spending isn't linear, which is why residents in so-called "tax and spend" jurisdictions still tend to have greater than average post-tax income. (The real problem is wealth distribution.)

But for basic services such as schools, fire, and sewer, what matters is geographic (horizontal) compactness. The more compact the area, the better the economies of scale, reducing per capita costs. However, at some point vertical density (i.e. building up) can overcome economies of scale provided by compactness by increasing infrastructure costs. Thus the per capita cost curve can end up being U-shaped within a fixed geographic area. See https://www.cgoodman.com/files/papers/national-sprawl-expend...

Housing has a similar U-shaped cost curve: skyscrapers have very high per unit construction and maintenance costs because of the need to switch to steel and other more expensive techniques. AFAIU, the most efficient form of housing in the U.S. is mid-rise developments, approx. 3 to 6 stories, though it varies according to available materials and allowed construction techniques. See https://urbanize.city/la/post/25-solutions-builder%E2%80%99s... (EDIT: Actually, that article describes the "missing middle" as 2-3 story developments, not 3-6. 3-6 is probably closer to what older, denser cities like San Francisco need more of, as most single-family homes are already tightly spaced 2-3 story buildings.)

Advocates of density from industry and academia are often misunderstood as demanding the type of developments you see in the inner core of large cities, such as skyscrapers. (As opposed to cityphile advocates who want live above French bakeries and near subway stations.[1]) But small rural and suburban towns can also be dense, and historically they were dense, even in the United States. If you've traveled enough around the U.S., especially on the old U.S. Highway system and away from the U.S. Interstate system (because Interstates were built to avoid small towns and thus in the present day most any town near an Interstates was likely developed after the 1950s), you'll see that most U.S. towns were built with relatively compact neighborhoods hugging dense commercial areas. (Especially true in the Northeast, Midwest, and West. Patterns of development in the American South seemed to have been historically distinct, a direct and indirect consequence of plantation culture.) And this was the pattern even after the U.S. became a car culture, though before white flight, enabled by the Interstate system, fundamentally changed expectations regarding geographic proximity to work and commercial services.

Perhaps the better term to use when promoting more cost efficient development is "compact", not "density". Too much density isn't cheap, though often desirable nonetheless. But when it comes to RoI, the characteristic to strive for is compactness. Having two skyscrapers a quarter mile apart with nothing in between is stupid. What you want is compactness, which in addition to providing economies of scale also, politically, minimizes the ability for developers and owners to externalize inefficient infrastructure costs; and then let the market decide vertical density.

[1] OTOH, this describes Paris, a city of mostly mid-rises. I think it's just that Americans in general, even urbanites, have a skewed perception of density informed by our culture, such as the prominence of major cities like New York and Chicago, and especially their downtowns, in depicting urbanity.