I like random encounters. – At times they can be mundane, but other times they can lead to gold
I have seen players follow them into all sorts of red herrings of their own invention. When players pick up on unintended things and follow them, maybe go with it and let them lead you. Give them something they are looking for that you did not plan. Maybe come up with a couple twists to throw in there. You can puzzle together the pieces as it goes. They might ‘figure it out’ for you before you can come up with something.
Random encounters with combat opponents that live or escape can lead to great things. Bring them back down the road a few game sessions. Give them a scar or injury they are mad at the Player characters over. Make them seek revenge against the players. Sometimes after a low level encounter with a random brigand that gets away can lead you to follow them up levels and create a villain that the players become invested in and truly hate. Have the villain show up to taunt the players when they are at a big disadvantage. Let the players follow those NPCs that piss them off and they grow to hate.
Searching a statue that the module does not mention anything magic about or any secret compartments? Why not just put something there to reward them? Give them what they want and are looking for. Maybe they find something mundane another red herring, but they might take those red herrings and run with them, and you can again throw in twists and slowly create something out of it. The players do not have to know if you have any plan for it or not, you can go with it, they are. Improvise
Improvise in response to the players. Don’t let your plan, or the pre-designed module hold you back or become disappointing to players. Improvise in ways that give them what they seem to want, or at least a few breadcrumbs. Don’t give too much, but sometimes the breadcrumbs are better than a big reward as they will lead the players to run with it and take it more places and you can continue to follow that with other ideas that you come up with along the way. Perhaps you only have a vague idea, throw it out there you can figure it out as you go. If you are listening to players plot and plan, they might just give you the ideas you need to fill in the blanks
Don’t get too invested in your own ideas or set in what you want to do. I plan way more than what I end up running in game. I have planned far more than my players have ever got through, and I have played through a great deal that I never planned and just had to wing it.
Random encounters do not have to always be rolled at the table. Roll and plan a few interesting ones that you have prepared and are ready to pull out if they roll for a random encounter.
I like to use lots of books of random tables to come up with things I would have never thought of. There are tons of third-party ones out there that are affordable. Some of my favorites in recent years are the Book of Random Table Series by Matt Davids. There are quite a few of these available as print on demand or pdf.
I keep a list of names to improvise with when the players go looking for a person or shop I did not plan. When I must pull out a name maybe have a list prepared and a few ideas of vague characters you can pull up. When I do those extra steps, those NPCs end up being more popular ones. You cannot always predict where the players will follow and try to get into, so make vague ideas and options you can run with. You know, you get to town and suddenly that one PC wants to visit the taylor, cobbler or some other shop you did not anticipate. Let’s follow them there and let that player have that moment to interact.
To me the biggest difference between a sandbox and a railroad campaign is player autonomy and self-determination. I have heard DM’s complaining about players who ruin the game. Sure, there are times players might get out of hand and do things that might need to be reeled back in, but if it is a power struggle between the DM and the players so the DM can tell the story they want to tell maybe that DM should write a book instead.