Just to complement rachaelbe's comprehensive answer, the issue for the UK research councils is not so much the nationality of the applicant, but whether the applicant fulfils the residency requirement.
In the case of the Economic and Social Research Council (ESRC), and the other research councils are likely to have similar rules, in order to receive both payment of fees and a stipend, everybody needs to: 1) have settled status in the UK, meaning that there are no restrictions on how long they can stay, 2) have been been 'ordinarily resident' in the UK for three years prior to the start of the studentship grant, and 3) have not been residing in the UK wholly or mainly for the purpose of full-time education. This last is waived in the case of UK and EU nationals. Interestingly therefore, being a British citizen is not enough to qualify; British citizens must be ordinarily resident in the UK. For the ESRC, where there are shortages of suitable students (in advanced quantitative methods and economics), these rules have been relaxed in certain doctoral training centres. The full rules are available.
I guess the reason for the residency rules is that the government wishes to fund students who already have a strong connection to the UK, i.e. those who are likely to want to remain in the UK after completion of their PhD studies.... I absolutely would agree that if the vacancies were available to everyone in the world, the quality of applicants would be higher. In advanced quantitative methods, it is difficult to find students who satisfy the residency criteria who would be suitable for the PhD programme and fully funded posts often end up being re-advertized.