Hold your horses! :o)
Ok. First of all, you need to define if an animated gif is what you need. This depends on the image you have, the type of animation you want, and the place on where you are going to put the animation.
I am making a semi-random list of ideas of several options you have to animate stuff... especially for a web page, (Which I am assuming you want the animation for)
1. Animated Gif
Normally it is best to use it at real scale, if the image is 400x400px display it as 400x400 px, do not scale it or blow it up to cover all background.
Use as few frames as possible, normally for a loop.
Use flat design style images, with a limited palette.
The background of the GIF should match (since the planning stage) the final background it will have.
But you have several other options:
It can animate exported assets from illustrator to PNG or SVG...
But probably this is out of the realm of graphic design and more into programming... so let's forget this for now.
3. Using a specific JS
For example, if the thing you want to animate is snow... search for some codes already made you can use:
4. Animating using CSS
This is on the realm of graphic web designers... But you need how to code HTML and CSS.
But this will not be random at all, this will be keyframe animations.
6. Looping a background
This is the approach you are describing... which is not a good idea because this needs to load the entire image each time.
You can do it using PNG sprites animation, and animating them using CSS.
If you still want to go with animated gif... you can use Blender (blender.org) which is free and assigning emission materials and turning off shadows, to have a flat look.
Normally you will have keyframe animation... or you can add particle systems to generate really random stuff... or you can use parametric animation... The possibilities are endless.