Will a single horse get lonely?
Yes, and it is not only a question of kindness: appropriate company is one of the five welfare needs an owner must meet in law.

Yes, and it’s not only a question of kindness. Defra’s Code of Practice for the Welfare of Horses, Ponies, Donkeys and their Hybrids lists the five things the Animal Welfare Act 2006 requires you to provide, and one of them is that the horse “has appropriate company”.
The code is unusually direct on what that means. Section 4.1 reads: “Horses are herd animals and in the wild would live in relatively stable social groups. They should be able to socialise with members of their own species. Isolating a horse from other horses can have a negative psychological impact.” It allows other animals as a fallback but doesn’t pretend they are equivalent — “the company of other horses is by far the better option”.
It also names the situation that catches owners out: horses “may become distressed if separated from other horses, or from a horse with which they have formed a pair bond”. That’s the horse left behind after a companion dies, and it’s worth planning for. Company is only one of the five needs: feeding and shelter and rugging are the ones owners ask about most.
