I concur with those saying it’s very largely about the characters. The companions especially, but other compelling characters too.
Getting it exactly right, enough to create a fandom around them is probably a bit of a black art. You need interesting characters, good performances, a balance between serious and emotional moments and some lighthearted humour. Basically making characters people actually care about.
For widespread appeal, it’s probably necessary to make them fully voiced and animated and for that to be done well.
Of the games mentioned, KOTOR probably had it, Mass Effect had it (and lost it with Andromeda), Dragon Age had it and it remains to be seen if they still have it. I think the Witcher 3 had it. BG3 has it too, and they’ve done it when YouTube and social media are so prominent.
It’s not the only factor of course. It still needs to be a good game that people enjoy playing.