There are two main PC motivations in rpgs. Firstly, the pursuit of personal gain, usually money and/or magic items. Secondly the desire to defeat evil.
The first motivation, personal gain, works well with sandbox play because the game world typically contains a great many opportunities to acquire wealth and magic items - there are lots of dungeons. The second motivation, defeat evil, doesn't work so well because the amount of evil beings within easy reach of the PCs and also actively and obviously causing harm will be far fewer.
A third possible motivation is the pursuit of glory, like the heroes of the Iliad or the PCs in Pendragon, but this is unusual in rpgs. A fourth, thrillseeking, is also unusual.
Once the PCs have achieved significant wealth it's hard to justify why they would want more. Or at least, why they would expose themselves to great danger in pursuit of more. So the first motivation, personal gain, doesn't work well for long term campaign play. The second motivation, defeat evil, does as there will always be more evil.
How does one successfully combine sandbox and campaign play? The answer, it seems to me, is PCs who are motivated by personal gain but, if they ever successfully acquire fortunes, immediately lose or quickly squander them, in the manner of Conan.
Well the big thing missing here are the more complex motivations that real people have. I describe my campaign as a living sandbox. That is, there are all sorts of things going on in the background that might come into play. Politics, schemes, romance, along with criminal elements, etc.
The PCs are well grounded in the world, with families, responsibilities, non-adventuring goals, likes, dislikes, etc. in addition, each player has multiple characters that come in and out of play as they desire, and they are often introducing new ones while others retire to normal life, perhaps to return to active adventuring in the future.
The campaign itself often focuses on politics, wars, monstrous threats, evil organization threats, being hired by various individuals such as wizards for rare ingredients, nobles for hunting parties, merchants for traveling, etc.
The style encourages frequent visits home to recover and recuperate, especially at lower levels, and at higher levels their goals are usually centered around things other than the two you mentioned, although it is often closer to the defeat evil thing.
More importantly, I don’t generally do BBEGs. Oh sure there are important and powerful villains, but most have a sizable organization. Powerful villains aren’t powerful because they are good in a dramatic final confrontation with the PCs. No, they are powerful because they have a lot of people willing and able to do their dirty work, and they are very good at not getting caught in situations like a final showdown with the PCs. Think more like the mob, nazis, SPECTRE and similar organizations. Most of the time you’re fooling specific plans and schemes, and occasionally taking down somebody important, but most of the time you’re just staying one step ahead of them.
The sandbox aspect is that the players are in full control of where they go and what they do. The campaign aspect is that there are too many options to choose. While there are dungeons, and lots of them, just getting to the ones far enough from civilization that they haven’t been plundered can be deadly in and if itself, as are the many adventures to find the location itself. And they are deadly when they get there.
The biggest of monsters, such as dragons, are nearly impossible to kill. Even high-level characters are in way over their head against an ancient dragon, beholder, or lich. Our game isn’t about balance, and it’s not about super heroes. The heroes are the ones that survive, and might even prevail, despite the odds.
We totally agree about the wealth thing, and in a small town the first adventure is like winning the lottery. But small towns also have a precarious position in the world, and if the PCs care about their town and the people in it, then they also have other motivations.
Of course, winning the lottery, so to speak, does result in quite a few retired adventurers. That’s ok and part of the reason everybody has multiple characters.
Ultimately, long-term campaign play can be combined with a sandbox very easily. Expand your options and motivations and develop complex characters rather than one-dimensional ones with a single motivation.