my kids at primary school were like this - I was rubbish at making school mum friends - DD was fine in primary school, not massively popular but fund friends then in secondary school and mostly came through unscathed (odd falling out etc and things fell apart at 6th form - but that is another post). She is adult and has friends, boyfriend, works and doesn't mix with anyone she went to school with.
DS was very unpopular at primary school - bullied, sad and only really had one friend. We tried and were blanked, he was never invited to parties or playdates etc.
He joined beavers/cubs which gave him friends out of school. They were the ones invited to his birthday parties and who's Mum's I made friends with - and he was invited to their parties.
He went to Secondary school and found his place - he is in a popular group - nice kids - he is 15 (Y11) has a great social life, friends, goes to a youth theatre group and has made friends there too.
Some kids just don't gel in their schools and need to find where they belong. Although a perfectly good primary school - clearly there were no natural friends for him - but he found them in secondary school.
It is heartbreaking to see when your child is sad - but there should hopefully be a change when he moves on.
I would recommend finding something he likes out of school to make friends at.