Minced oaths, from well-known ones like "gosh" and "darn" and "heck" and "fricking", to more obscure ones, are common in the real world, but even more so in fiction and especially fantasy. I've read children's stories, set in versions of the real world with some fantasy elements, where characters say "ruddy" or "bliddy" instead of the mild swear-word "bloody". In fully imaginary worlds, it's even more plausible to have completely invented curses.
The usual reason for this, I think, is to keep the book family-friendly while still having a realistic amount of characters swearing. This particularly applies to the cases like "ruddy" and "bliddy" mentioned above, but can also apply to fantasy like The Dragonriders of Pern set in entirely imaginary worlds.
Another reason is to increase immersion in the imaginary world. You wouldn't expect people in Pern to utter oaths like "oh Christ!", because Jesus Christ is a religious figure in our world. Creating some invented curses, especially those which have some theme related to that imaginary world (like dragon eggs in Pern), helps to remind the reader that this is an imaginary world and make them feel more immersed in it.
Specifically, many real-world oaths, especially older ones, are ultimately based on something religious, ranging from "goddamn" to "hell" and many others. Swearing by the legendary Faranth could be seen as the Pern equivalent of swearing by Jesus Christ in real-life Europe or America.
Cf., for example, the Wheel of Time series, another work of fantasy set in an entirely imaginary world, where we see a lot of characters using various curses like "oh Light" (the Light being a sort of mystic source of goodness from the Creator, often used metaphorically) or "blood and ashes" (an invented curse but similar enough to some real ones like "bloody" that it's clearly a curse). Some of them reflect facets of particular cultures: e.g. Shienarans use "peace" as a general blessing, even in odd contexts like "peace favour your sword", because they're Borderland people who've never known peace.