A few things. Keep in mind that people will disagree but I had a good Marathon this spring due to a few things.
1. Mileage. I needed an average of 55 miles a week for 5 months to run a good one. You can't run two weeks of 60 mpw and then one week of 15 miles the following week and tell people you are running 60mpw. You need to be consistent with mileage.
2. Long Runs. Lots of them. I had two 17 milers, two 19 milers, a 15 miler, and two 22 mile runs. Based on my pace for my long runs, I was able to determine my goal pace. This is where people disagree, but I think it's very important to hit the long runs pretty hard. These are workouts and I ran easy for the rest of the week except for some hard intervals midweek.
For example, if you want to run a 7:15 pace for a marathon, I think you try to hit 7:20's in your long runs. Like most people say, the race starts at 20, but for me the race really started at 22 and I knew I was confident I could maintain my pace for another 4 miles despite the quads getting heavy. You absolutely, positively, need to get comfortable at race pace. It is silly to me to think that you can do long runs at 8:20 pace and then expect to cut down 40 seconds per mile on race day. That's how people hit the wall.
3. Don't be afraid to carb up heavy two days before the race. Go big on Pizza and Pasta. The day before I drank a lot of water and ate normally. I had a lot in reserves and didn't feel like a bloated mess on race day.
4. Hit many water stations...take lots of GU's. I went through 4 GU's in my race and stayed away from Gatorade.
5. Consistent pacing. I ran 6:55's the whole way and never changed my pace until the final 2 miles where I hammered them as best as I could and negative split it. I was constantly staring at my watch and having to slow down because I had the urge to run faster. You need to hold back. This is how it's done if you want to be absolutely flying by people at mile 23.
The marathon is a mental challenge and about being very patient. People run bad marathons because they run on instinct instead of actual logic.