Start by dragging an image into Gimp or clicking on Files then Open.
Click the icon on the left of the Layers box and then select "Transparency".
Then right click on the top image and click Add Alpha channel.
Select the gradient tool. It looks like a square.
Select the rainbow gradient by clicking on the rectangle with gradients in it and scrolling down. Feel free to adjust what type it's going to be like Linear etcetera in the drop-down menu.
Click on the bottom layer (the transparent one) and click and drag. The length of how long you drag will affect the gradient.
Once you have found a gradient you like, click on the layer with the image and rub out the background of the image to reveal the rainbow underneath. If this isn't working, make sure to add an alpha channel to the top image by right-clicking on the layer.