Because the road from your house to the next is longer, therefore it requires more maintenance. Same with the electric wires, the water pipes, the sewers etc.
Jeremy Clarkson has a pub in West Oxfordshire, a couple of miles from the nearest settlement. The electrical supply is insufficient and needs renewing, the cost to do so would be £200k which is obviously unaffordable so he has to use generators. If however there were two properties sharing the cost, it would be £100k each, four properties £50k each etc. Extreme example, but it does translate into the infrastructure on your street. Do you not see how you can more efficiently serve the 40k people per square mile in Hackney than the 9k people per square mile in Richmond? Obviously the more people you serve, the thicker the wire needs to be, but the other costs like the telegraph poles, utility cuts and labour are fixed and can be shared between households.
Services are more expensive too, it takes longer for the police/ambulance/fire brigade/school buses/social care/pizza delivery to get to you (assuming that your house is typical of the area), therefore there needs to be more provision for 10k people living in sprawling suburbia than for 10k people living in blocks of flats. Obviously in the case of pizza delivery, the less-populated areas just don't get served, but other services are essential. A community carer in Hackney can quickly walk from one client to the next, whereas one in an outer borough may need to drive, therefore social care costs in an outer borough (never mind a properly rural area) are higher per patient than in Hackney. This is one of the many reasons that council tax rates tend to be lower in cities than in the countryside.