For Test Matches, they seem to be picking Buttler out of hope that he'll perform if England need a rapid run chase or someone to marshal the tail.
Foakes is a better keeper and, for most Test Match circumstances, I think he's a better batting choice.