The reason he uses a sword is obvious: Because he is the main character, and the sword is symbolic of leadership.
Yes, a spear is obviously the right choice of weapon under the circumstances. For most hunting OR warfare purposes in a world without guns, spears would be the most common weapon... because they're a cheap, simple means of greatly extending reach.
But swords, being more expensive and more versatile in close quarters, became symbols of leadership or nobility. Unsurprisingly this has led to swords being the standard weapon of "the hero" in fantasy fiction... and to some extent, the standard weapon of absolutely fuckin everyone because generally named characters in fiction don't have to fight in formation, and don't have to concern themselves with forging / maintenance costs / effort. The people most likely to have spears in fantasy fiction are town guards, peasant militia, and random nobodies... and at least that much is somewhat realistic, as a long sharpened stick is a cheap, easy combat-multiplier.