Ask for a second opinion on this, because my Smash knowledge is a bit old, but in general, you just want to run away as far as you can from the sword.
When Marth's extremely aggressive, there's really not that much you can do about it. Fireball deterrence is pretty useless and puts you in a dangerous spot unless he's on the other side of the stage. Mario doesn't have anything that can even remotely compete with Marth's massive disjointed hitbox. You basically HAVE to run.
When you're not running away directly, you're trying to get inside. You do that by dashdancing to bait certain laggier attacks (u-tilt sort of, f-smash, f-tilt, d-tilt) and taking advantage of that said attack with a quick shffl'd aerial. Or you can wavedashing back, or wavedash out-of-shield (great for shifting immediately from defense to offense, especially when you wavedash out-of-shield into a grab or d-smash). Spot-dodging is also handy if you can predict a Marth's grabs or f-smash. Selectively choosing when to roll can also throw off a Marth's rhythm, provided that you're smart about it.
You should try to mix in some offensive moves now and then, just to throw Marth off. . .obviously not a lot of it (because Mario is at a horrible disadvantage when it comes to offense), but it really is necessary in getting an idea of Marth's patterns. Wavedash forward + f-tilt, or wavejabbing, or limited shffl'd sex kicks and b-airs are good for this kind of stuff.
During this whole run-away and evasive maneuvering routine, the one thing you need to do is to look very carefully at how Marth responds to your evasiveness (or limited aggressive pokes). No Marth is 100% invulnerable; no matter how carefully the Marth sets up his offense, there WILL be holes. It's just your job to see where they are.
Standard openings are after Marth's f-smash (your biggest opportunity; definitely learn to get a feel as to when a Marth will pull out a f-smash), right in between his double-f-airs-in-one-short-hop (shielding the first one, the jump-cancelling into an u-air right before the second f-air comes out), during his f-airs (you can crouch-cancel the non-sweetspotted ones pretty well at low %s into a d-smash), missed grabs (try to see a grab pattern), etc.
Other Marth advice is to edgeguard aggressively (keep him off the stage no matter what), learn his sword range (the more familiar you are with it, the more formidable an evasive game you have), learn to DI properly (away from f-airs, behind his u-tilts, against f-smash, etc.) and avoid combo'ing (it doesn't work on Marth, ever).
The last part bears a bit of repeating, mostly because as Mario, you'll be tempted to go into u-airs and u-tilts and your standard bread-and-butter. Try combo'ing the Marth; if he lets you do it, great. Except, Marth can break out of any combo Mario dishes out with his f-air, so you're much better off playing it safe with limited 2-3 hit combos, and backing off.
Err. . .I think that may be it. . .if there's anything else I missed or got wrong, someone please jump in.