The word fojfoje has a repetition of the root foj. Why and how does this alter the meaning of the word, compared to the word foje?
This is a very interesting question. I think reduplication plays a role in Esperanto which hasn’t been sufficiently explored yet. What is the difference between
Mi foje ludas ŝakon
Mi fojfoje ludas ŝakon
Post multaj klopodoj nia teamo fine venkis
Post multaj klopodoj nia teamo finfine venkis
As far as I can tell, the reduplicated forms not only increase the intensity of the adverb, but also its expressiveness. That seems to be the reason why in spoken Esperanto, you often hear things like ”La ĉambro estis plenplena je homoj” instead of ”La ĉambro estis plenega je homoj”, for example. Such reduplications give speakers a room for ”emotional exaggerations” that are not always logically analysable, but immediately understood in the human context.
Perhaps it will be interesting for you to know that the same reduplication of words is often used in russian language (possibly in other slavic languages too) - in exactly the same way as in Esperanto (in order to increase the intensity of the word and its expressiveness).
For examples: "полным-полна" (plenplena), "белым-бело" (blankblanke), "в конце концов" (finfine) etc.
So, probably, Zamenhof borrowed this feature from russian (or from his native polish) language.
I had, as I recall, a fairly lengthy exchange with Bertilo on this very question. It's his position that true reduplication does not exist in Esperanto and that all cases which have been called reduplication can be explained as normal word-building.
I am not sure I agree, and neither to the authors of the Wikipedia article who wrote:
Reduplication is only marginally used in Esperanto. It has an intensifying effect similar to that of the suffix -eg-. The common examples are plenplena (chock-full), from plena (full), finfine (finally, at last), from fina (final), and fojfoje (once in a while), from foje (once, sometimes). So far, reduplication has only been used with monosyllabic roots that don't require an epenthetic vowel when compounded.
Related specifically to fojfoje Bertilo agreed that it's not simply normal word building, but explained further by saying:
"Fojfoje" estas pli bona ekzemplo. Rilate tiun ekzemplon oni povas eble diskuti, ĉu tie tamen io simila al duobligado rolis. Sed ĝi estas tiam tute izolita ekzemplo, kaprica kuriozaĵo.
So, to answer your question as to why - people can disagree about the reason. As for what, it simply means "less often than regular foje". In the end, this is just something one needs to learn when learning Esperanto.
All or most of the exchange is recorded here.