Why did Bartholomew Kuma want to take Luffy's head after the Thriller Bark Arc? Wasn't he a member of Revolutionary Army and secretly working for his father Dragon? If it wasn't for Zoro, Luffy would have died.
Bartholomew Kuma was a undercover member of revolutionary army, he cannot just say to the marines that he wont kill Luffy. Similarly, Straw Hat Pirates and Rolling Pirates (Lola's group of pirates) heard the order of the marines and Kuma can't just take a risk of blowing his own cover.
Hence he pretends to fight them all, since that also gives him a chance to check the loyalty of his crew and what are there potential.
The answer contains spoiler from the Sabaody Arc:
I suspect that he was never after Luffy's head to begin with. I'm thinking that Kuma did, in fact, go to Thriller Bark at the behest of the WG however he intended, first to test the Straw Hats (as someone above said) and secondly to send them off (as he eventually does later on Sabaody). However, he was touched by the way everyone tried to protect Luffy and, seeing their desperation/determination couldn't bring himself to do it. Also bear in mind the situation on Sabaody basically forced his hand (if he hadn't sent them off Kizaru would have owned them eventually) while on Thriller Bark, they would be okay even if Kuma didn't send them off.