Yes, it is legal as long as you play at a reputable and licensed online casino. These casinos use certified random number generators to ensure that the game results are unbiased and random.