Here's how I would answer the question.
Most
new guns are not good investments. Like cars, they immediately drop in value the first time you use them. Some guns will eventually climb in value, but it usually takes decades to exceed their original value adjusted for inflation, and for many guns this may
never occur.
On the other hand, many
used guns are great invesments because they're already close to the bottom of the depreciation curve. Some guns will never be worth less than they are today. The trick is to buy the right one!
The bad news is that most common inexpensive .22LR rifles
(I assume it's a rifle because of where you posted this question) will never be serious collectibles because they've been sold in huge numbers. OTOH some are better than others. For instance, Ruger 10/22s hold their value really well because so many people modify them that there's a constant demand for serviceable receivers.
I want to buy a Glock 19 for ~$500. Should I factor in that private gun sales might be restricted in the future? Can you foresee a possibility that I would take a big loss on selling the gun?
Restrictions on private sales would probably make semi-auto prices go
up before the restrictions take effect. OTOH prices may go
down because so many people have stocked up on hi-cap 9mm's under the
assumption that restrictions are coming. If nothing happens within a few months, some of these people will probably decide that they need money more than they need 4 spare Glocks, and may be looking to dump one of them.
Who knows?
I'll say this. If you're not sure you really
want that 9mm, and you're only looking to buy it
primarily because you're concerned it will be banned later, IMHO you should look at something less expensive. IMHO the best deals on today's market in mainstream Western calibers are a new Ruger P-series, a new S&W Sigma, or a used metal-frame S&W (the ones with numerical model numbers like the 469, 910, and 5906,
not the new polymer M&P series, which are nice guns but are priced similar to Glocks).