The raid on the town occurs after nightfall once the heroes uncover the goblin's presence.
Random Encounter: event that occurs due to random chance/location/decision.
The party decides to explore a dire badger's lair while tracking the goblin's after the town raid.
Both of these things have a place at a gaming table in a fantasy world. The issue is how to deal with them in an appropriate fashion.
A GM should not have too many scripted events if he/she wants the players to feel like (or actually have agency) in the game. How involved do you feel watching a movie (hint: watching a movie is a series of scripted events you have no control over)? A large number of scripted events can be a major problem of heavy story based games, my rule of thumb is 3 per session *IF* they are necessary. One at the beginning to set the tone and get the players hooked into the session, one in the middle to create drama for the climax scene (this one often is more about the players creating the scene than anything I do) and one at the end that is a cliff-hanger to keep the players thinking about the game through the down time. However, if the GM/ST/DM runs from one event directly into the next, the players often feel like they are being railroaded to the climatic event the GM has already planned out - let the players figure out how to get from A to C by choosing to go through E, J and Q on their own, they will often create plenty of future game material along the way. The same can often be the case in very long story arcs for any genre of game, but seems to be less necessary in sandbox-style games.
Random Encounter -
Random encounters kill heavy story-based games. Inevitably, one of the main PCs will get killed in a random encounter and the replacement PC never fits into the same position effectively. "But without random encounters, how do you keep the tension up during a dungeon crawl/cross-country travel/forest adventure?" I didn't say take them out completely, on the contrary, I think increasing the number of random encounters might actually be called for - just not combat oriented ones. "But meeting merchants A1, A2 and A3 on a journey is boring." It's only boring if the GM lets it get boring. There is no limit to the types of random encounters a party can experience in any give environment - a gaze of beholders flies over; a core of elementals is seen (or felt if of the air variety); or just your random traveling snake-oil salesman - all serve to increase the anticipation and possibly open up new directions the game can move. Whatever it is, make it something that is interesting enough to spend more than a few seconds describing. "What if the players don't do anything?" So what if they don't, it's because they *chose* to do nothing, just as they can *choose* to do something.
"All that is great, but I still don't get why it really matters?" It matters because if you do nothing but scripted events, the players never feel like a part of the action and so nothing they do matters. If you do nothing but random events, the players feel like there is not real point to anything and nothing they do matters.