Ah, loops, Sonic's signature level design feature and omnipresent shape in cities across Sonic world. We have been through many of them without every thinking about their potential within the general level design - mostly because we have more interesting and more important things to do.
But it's about 3:30 AM here (daylight saving time) and I can't sleep. This must be a sign of God to make me develop more level design theory, so here I am. Let us talk about the functions of the loops in level design.

I... honestly don't know how come there isn't any Sonic stage with this name
Let's not think as gamers right now. Let's think as designers. Well, the loop-the-loop is a specific geometry shape that,
when subjected to the laws of physics, generates some kind of phenomenon on objects that move in it. In humans, going through one releases adrenaline because... well... it's thrilling. In short, an object needs enough speed to cross it without falling. To be specific, ignoring dissipative forces, it's kinetic energy when it enters the loop must surpass the maximum potential gravitational energy when it's on the top... I... think. Either way, this is an extremely uninteresting issue and doesn't really matter right now. What's really important is that there is a certain speed necessary to go through it.
Some people claimed the loops were obstacles because of this, but later another guy came up with a video showing how stupid this theory was, since nothing but holding forward is needed to overcome it. Indeed, loops can't be obstacles if they demand nothing but holding a button you were already going to hold anyway. If that was the case, we would have to consider each and every slope an obstacle, which would be stupid. However, we shouldn't dismiss this theory completely, because the loops are interesting features that aren't there for no reason at all.
If a certain amount of speed is required to go through a loop and it's very likely that the player will leave it at top speed, some points can be drawn:
- we know the probable speed the player will have at the beginning of the loop
- we know the probable speed the player will have at the end of the loop
This is an unvaluable tool to a level designer. If we know the condition a player will have after an event, but such even wasn't forced upon him/her, suddenly our possibilities expand for that moment. Let me give you an example:

Without a loop

With a loop
First-case scenario: we don't know if the player will be at top speed by the time s/he sees the platform. It depends on whether the player has already seen this area or not, whether s/he can beat the badnik without hesitating (and thus keeping momentum), whether s/he was at top speed before... it's not much clear what the conditions are to get this reward. What is certain, though, is that the player will have enough time to react, since it only depends on him/her.
Second-case scenario: we know that the player will be at top speed once s/he leaves the loop; we know s/he'll face the badnik once that happens - the likelihood of trying to defeat this badnik by rolling instead of jumping is something to consider, so we can design a badnik that doesn't allow that if we really feel like being evil; we know there is not enough space to reach top speed otherwise. There: now you have a clear challenge. One can only get the reward if one successfully uses reflexes twice: once to destroy the badnik (which now is not only an obstacle, but also a skill toll), once to notice the platform and jump right afterwards. And, at first glance, there is only one chance for that.
Simple, isn't it?
But let me tell you: what is the difference, then, from a loop to a dash pad? Well, don't go there. The difference is that player input is needed in one and not in the other,
which is why it's stupid as hell to put a dash pad right before a loop. "Oh, but it's 3D" is not an excuse. If crossing the loop doesn't require any input, it's not needed. And it's not like you can compare it to a roller coaster, since it's not you there - it's Sonic. The loop doesn't hold any value by itself, except that of uniqueness.
True, it doesn't require any different movement from the player, but it
does require the most basic input with a certain intensity. Oh, actually, let me correct myself - it demands a certain amount of speed. Such speed can come from various ways, and this is why it can be evil, too.
Consider the following:

Don't you call me out for my artistic skills. Just don't.
For all that matters, let's assume it's not possible to go through the loop just by pressing right. Now the loop has
effectively become an obstacle, since it demands a different input for the player to continue. In this case, it makes the spindash obligatory. It turns out I
hate this kind of obstacle, because it's just a forced tutorial. It's less offensive than a "Press Down+A to perform a spindash" screen, but still.
And if you come and try to rebutt this point with that Egoraptor video about Megaman X, I will turn on a mechanical fan right before your nose and force you to stand there until you catch a cold. That video is about
showing the player what he has to do. It's about subtle tutorials. If Sonic spindashes on the game's opening or as a menu icon, that's a subtle tutorial. Forcing you to use the spindash when the game doesn't make sure you know such a thing exists isn't. And yes, Sonic 3 & Knuckles did that wrong with the boulders. The optimal funcion of the spindash is that of easing the pain of having to come back just to get enough speed. Some parts in Sonic 1 got clunky because of that. But it should never ever be obligatory.
EDIT: Oh, I almost forgot.

Loops are probably the feature with the most potential when talking about playing with Gestalt. Because fuck you, Gestalt.