They were built because SpongeBob needed them to escape from the jellyfish that wouldn't leave him alone. They refuse to leave him alone because a strong wind is blowing, and it makes a tune when it blows through SpongeBob's holes that jellyfish seem to love. The jellyfishes' interference prevent SpongeBob from going about his day.
SpongeBob is forced to take refuge in a cave where the wind doesn't blow. SpongeBob waits for the wind to stop blowing, to no avail. He eventually creates a stone carving of himself out of insanity. When SpongeBob blows into one of its holes, he discovers that it made a tune. When he tries to use it to distract the jellyfish, it only makes a shrill noise that made them angry.
SpongeBob concludes that he needed to make another stone carving of himself in a different size, but he doesn't know how big to make them, so he makes a bunch of them. He ends up making a bunch of large ones and puts them in a circle.
Their tune is perfect and the soothing melodies they produced are successful in distracting the jellyfish, allowing SpongeBob to finally make a hasty retreat.
3,000 years later, a race of light purple aliens is seen, and SpongeHenge is now a tourist attraction. The aliens don't know who built the henge or why they were built; they only know that their tune causes the annual migration of jellyfish to fall in love with the sound. SpongeBob's laugh can be heard in one of the statues.
The circle of SpongeBob statues is a parody of Stonehenge.
SpongeBob makes a lot of statues because he doesn't know which one is the right size, but they all end up being the same size.