The discount curve is not truly risk free, but it's called "riskfree" because it's A) where you would invest your funds while replicating an option or security and B) it serves as a reference point for valuing other assets.
So for example if you're replicating a swaption, then the assumption is that you're holding the premium and earning LIBOR or its replacement, which over the term of the option is the swap rate.
Also it's considered "riskfree" so that any rate that changes relative to it could be considered a repricing of a specific asset, rather than a repricing of your reference rate. This is helpful to look at the comparative repricings of assets over time, for example swap spreads on different types of bonds.
It's not truly "riskfree" because a swap is a transaction between 2 commercial banks, so there is some collateral transaction risk. However, it is a pretty good option. For example it is more objective than government bonds, which have default risks but also liquidity risks, so a discount curve constructed from government bond yields could cause more biases. In particular "on the run" treasuries could have artificially low yields because of their demand as hedging instruments, and using them could distort your values for long-term options and bonds with embedded options.