The question didn't specify which game or competitive format/ruleset it was asking about. Normally I would hide vague questions, but hiding this specific question risks losing search engine hits. I guess I'll have to answer it for the most common use cases to appease the Algorithm. And because people will likely continue reading these answers for years in the future, the competitive parts of the answer will focus more on past generation OUs instead of current generation formats. I think this will keep the answer relevant for longer.
RSE singleplayer
Natures are usually pretty negligible in-game, as the stats you lose from a bad nature are pretty insignificant compared to the stats you gain from leveling up. Swampert's strongest moves in RSE are surf and earthquake, so you should be fine as long as your nature doesn't lower either of its attack stats.
ORAS singleplayer
Physical water moves exist now, which means Swampert doesn't care about its special attack stat as much anymore. Mega Swampert is also fast enough to outspeed a good number of opponents. So just soft-reset for a nature that doesn't lower physical attack or speed
Gen 3 OU
Swampert is one of the more versatile Pokemon in this metagame, which makes this part of the question tricky to answer. It's (usually) a physical wall that uses its strong defensive typing to check physical attackers like Aerodactyl, Tyranitar, Flygon, or Metagross, which means you (usually) want HP/Def investment and a nature that raises physical defense. Whether you use bold (- attack) or relaxed (- speed) depends on whether your Swampert uses earthquake, which itself depends on several other things. The 2 most common kinds of movesets are tanks and support/stall breakers. Tank Swampert sets (usually) use earthquake, hydro pump, ice beam, and relaxed nature to maximize damage against as many sweepers as possible, while support/stall breaking sets (usually) use surf and bold nature to do the most consistent damage using only one move slot and save the others for moves like protect, toxic, roar, or refresh. However, if your team doesn't have enough Blissey checks, you might want earthquake and relaxed nature on your stall breaker Swampert. There are also occasionally people who use offensive Swampert sets with timid or quiet nature.
Gen 4 OU
The physical special split means waterfall and ice punch are now physical, and any investment in physical attack will boost all of their damage. This lets Swampert run much more offensive sets than before, such as HP/Atk sets and Atk/Spe sets if you want to outspeed stuff like Machamp, Skarmory, Breloom, or Rotom. HP/Atk sets obviously use adamant nature. Whether you use jolly or adamant on an Atk/Spe set depends on whether you care about outspeeding a few things like Empoleon or 252 Spe Metagross. People also occasionally use specially offensive sets with modest or timid. More defensive tank earthquake ice beam HP/Def relaxed sets are still good, because it just needed a few changes (like replacing hydro pump with stealth rock) to counter new threats like Dragonite, Infernape, and Gliscor. A tank set can also use waterfall or ice punch with impish nature if you're really sure you want to do less damage to Gliscor. The toxic stall breaking sets are unfortunately almost never useful, as defensive teams are just less common than before, and the ones that still exist are using Pokemon like Clefable and Jirachi that aren't threatened by toxic.
Gen 7 OU
Swampert's role in this metagame is very simple. It run Atk/Spe and sweeps stuff. Whether you use adamant or jolly depends on whether you want to outspeed choice scarf Kartana.
Gen 8 OU
Flip turn and several electric type and poison type threats made Swampert once again useful as a tank, with minimum speed to maximize the chance that Swampert takes a hit for its teammates before using flip turn. Powerful special attackers like Slowking, Heatran, Tapu Koko, and Dragapult mean that Swampert is now usually better with specially defensive sets like HP/SpD sassy. People still occasionally use HP/Def relaxed for teams that need a physical wall, and of course you can use careful nature if you really want to outspeed Hippowdon or Tangrowth or something.
tldr
Gen 3 OU: HP/Def bold or relaxed
Gen 4 OU: Atk/Spe jolly or adamant, HP/Atk adamant, or HP/Def relaxed
Gen 7 OU: Atk/Spe jolly or adamant
Gen 8 OU: HP/SpD sassy
source
source
source
source
source
source