Sam Giancana claimed that he ordered the hit of Kennedy because they thought that they bought themselves a president when Joe Kennedy made a desk with Giancana to deliver Chicago which put Kennedy just over Nixon. But instead of being grateful, Bobby attacked Giancana and other mob bosses in congressional hearings.
Did Giancana really order the hit? Or was his claims simply the ramblings of an exiled (he was living in Mexico at the time) ex-mob-boss looking to seem important again? Maybe it was the CIA, or maybe even Castro. We'll never really know.
Personally, I believe the mafia theory. What's interesting is that Giancana and other mob bosses worked with the CIA on the Bay of Pigs fiasco. Maybe the mob and the CIA were in on the Kennedy assignation together.