I live in Wyoming and know both parks quite well.
First, I don't know your experience with touring and where you are from - i.e. back East.
Why? Because Going to the Sun Road, although not too difficult, is a tough start.
Not to mention that it makes a better dessert than first course.
In which case, riding from Yellowstone to Glacier would make more sense.
You would get an overall elevation loss, slightly prevailing winds, and the sun at your back, too.
As for route, I would suggest an easterly one largely following US 89. Whether S-to-N or N-to-S.
US 89 has significantly less traffic than other routes - plus you get stunning views of the Front Range.
Here's a map published by Montana DOT with summer traffic numbers:
All three highways heading north from Yellowstone US 287, US 191, and US 89 have a good deal of traffic -
But the US 89 route has a paved county road on the east side of the river that is virtually empty.
Plus the historic Chico Hot Springs where you can rent a cabin and soak.
North of Livingston, traffic on US 89 drops to very low levels with mountain ranges on both sides.
White Sulphur Springs is a funky springs town - certainly not an Aspen or Bend.
From there, US 89 heads over the Belt Mountains and down a long creek course with lots of camping.
US 287 heading into Helena has shoulders, but an insane level of traffic. (Your route above)
There is a back way into Great Falls from Belt with only a limited amount of highway riding.
Then the great stretch of US 89 heading up thru Choteau and Browning.
Hwy 83 on the west side had twice the traffic, fewer shoulders, and limited views.
Make sure to take in either Two Medicine or Many Glacier - or both - on the east side.
They have spectacular lakes and alpine scenery - Many Glacier has a cafe plus the elegant hotel.
If you are car supported, you will not be able to use the hiker/biker campsites in Yellowstone or Glacier.
Also, lodging is pricey and often booked long in advance near the parks.
I would urge you to finalize your plans and reserve camping/cabins - at least for the parks - by May 1.
Here's a tour I took 11 years ago using the US 90 route:
PS - North American Indian Days, one of the largest pow-wows, will be July 7-10 this year in Browning.