tl;dr- While pure gold's too fragile to be a good material for swords in general, it'd be especially problematic in rapiers as they're already prone to breaking when composed of stronger metals.
Rapiers are already light, thin blades:
\$\hspace{3cm}\$
.
They're also prone to breaking:
How strong were rapier blades, couldn’t they break easily?
There is substantial historical evidence for rapiers breaking during fights (in bodies and against other weapons), and I have held several real ones that had broken or even bent points. I’ve examined many others that to me felt so thin and light I am sure they would readily break if used to slash with or even if seized by a hand and forced to bend.
-"Questions and Answers About the Rapier"
As for gold as a working material, pure gold's doesn't tend to resist deformation very well. It's easily enough deformed that even fine jewerly uses an alloy of gold with other metals instead.
So, while a golden rapier might make for an interesting decoration, it wouldn't seem to be a reliable weapon.
Tangential: Rapiers aren't really general-purpose weapons
Rapiers already aren't general-purpose weapons; instead:
What kind of sword is a rapier?
The best answer I can give is that the true rapier is a long, narrow, rigid, nearly edgeless single-hand thrusting blade with a thick, tapering cross-section and very narrow and sharp point. There is no question rapiers vary in their shape, length, and width and especially in their hilt configuration. But rapiers are generally thin, light, fast, and well-balanced thrusting swords intended for unarmored single-combat.
-"Questions and Answers About the Rapier"
This is, it's already a bit of a stretch to use a rapier in D&D-style combat since it's really just for "unarmored single-combat" between humanoids; rapiers weren't meant for stuff like attacking armored opponents, non-humanoids like dragons, etc..
Since D&D's already stretching things by having rapiers being used as general-purpose weapons, it's probably best to avoid stretching it further — unless your group has no concern for this sort of thing, in which case, I suppose you could house-rule that gold has properties entirely distinct from those found in real-life or something.