It's not like he hasn't jumped around F1 teams in the past - IIRC - Minardi > Renault > McLaren > Renault > Ferrari > McLaren...... And he's on record that he wants to emulate Graham Hill's triple crown.
So, as McLaren F1 isn't up anywhere near the frontrunners or likely to be anytime soon, it's a logical move for him to try and let him tick that box while retaining his services at McLaren - and the tie up is probably more about Honda engines. I think the Indy car is the series standard Dallara chassis with a Honda engine, and is the sixth car that the Andretti team were going to run with Stefan Wilson driving.
As to Le Mans, I reckon he'll doubtless have clocked what others of his ilk, e.g. Webber and Hulkenburg done there (noting he would have filled the latter's 2015 Porsche seat if Honda hadn't have blocked the deal - ironic, given H won first time out!) Rubens is there in LMP2 this year, and it's not like Alonso is long in the tooth at 35. A good catch for a team at some point in the nearish future. His McLaren F1 contract runs out at the end this season too, so maybe the Indy 500 run is a sweetener to keep him for the rest of the season, or to persuade him to extend it.
For Le Mans then I reckon 2018, perhaps McLaren, but in my mind more likely Porsche. Or, perhaps Ferrari if they return to LMP1.... Mind you, with the F1 schedule this year, if a spare seat came about at short notice, he could do the Indy 500, then LM pre-qual on 4 June, and then the race proper in the weekend between Canada and Azerbaijan.....
MG Mark