You need an animation program. I use GIF Construction Set, but there are lots of programs out there. Most of them cost money, though. It's hard to find a good free animation program.
Once you have the program, then it's just a matter of making a series of still images (frames) that will look good when animated together. The animation program will do all the work for you after that point. You just tell the program which images you want to animate, add some effects (if you want to) and the program will combine everything into one animated image for you :)