Wow, Grand Canyon & Yellowstone in one trip. I hope you are planning to spend 2-3 months at this. As JOHNBURKE pointed out, there's a lot between those places you wouldn't want to miss, and putting more than an hour into each of them is going to be an incredible trip.
When you should go is a tough one. Grand Canyon south rim is open all year if I'm not mistaken, and the canyon itself is incredible any time, and NEVER the same twice. The north rim is an entirely different world, is open only during the summer, and well worth the visit, especially as it is not as popular as south rim and therefore much less crowded. Yellowstone is mostly only a summer place, as it is mostly closed in winter. It is also very crowded. I would recommend either the first couple weeks it is open in the spring or the last couple in the fall to avoid the worst of the crowds.
Whenever you go, and however long you take, enjoy the journey, take lots of pictures, and make beautiful memories.