It's the same concept at flipping real estate. Buy a piece of land, wait for the value to go up, and resell it for a higher price than you paid for it. So, the concept is not illegal at all. The same could be said for:
flipping antiques
flipping cars
flipping real estate
flipping businesses
flipping baseball cards