It depends more upon your specific ambitions, finances, personal circumstances and the household/extended family dynamic than the distance.
A young healthy uni student with very obliging parents/siblings who frequently spoils them with lots of practical assistance or access to providers of freebies that would be expensive if purchased, probably should move very far away from their very generous relatives in order to obtain the maximum possible opportunity for independent adult life without much involvement from those family members whilst living at student accommodation nearby.
The type of older household members who have long been in the habit of doing things like: buying them everything they want, cleaning their bedroom, driving them wherever they want to go every day even when having received very little notice, doing their laundry, providing them with homecooked meals and access to large sums of money or credit card in their name as additional card holder to credit facilities with five digit limits.
For the average student who opts for a local uni charging local home students relatively low tuition fees having been raised in the average household by reasonably pleasant & helpful relatives or non-related legal guardians who always encouraged them to use their common sense, work hard, widen their skillsets and save up some cash for emergencies- renting a room in a bargain priced all inclusive houseshare/ student only studio complex within a 20min walk of where their closest relatives live may well be their best option.
Limited travel costs and the possibility of accomodation expenses easily covered by the student maintainence loan.
Easy to visit family members at weekends, during the holidays, attend special occasion gatherings or in the event of an emergency.
Yet also easy to learn how to live with housemates as a new adult studying and learning how to adapt to student life whilst at uni living away from their family members.
A teenage to early 20s aged student who has never lived alone or away from relatives and was raised within an overbearing household/ by ultra ambitious 'helicopter' parents will probably want to put a lot of distance between themselves & all those members of their household.
So that they can maximise the potential opportunities for them to be able to enjoy their privacy and freedom at uni as they learn how to become self-reliant adults deciding upon the direction of their future life.
Whilst a student who has been raised within either a very dysfunctional household, by habitually criminal adults or in toxic domestic environment with a history of abusive incidents will know that they need to run for the hills as far away as they can get to avoid their health and all prospects of building a happy future life being ruined by a continuation of the vicious circle.
I was a lifelong Londoner until my mid twenties and now I wish that I had moved out of London for my undergrad.
I was raised in a toxic & controlling household and grew up surrounded by unreasonable people who constantly imposed their foul thuggery and bizarre rules upon me.
I escaped 10 years ago before a levels were over but should have known better than to risk staying in London for so many years of my student life.