I never believed that cock-and-bull story about Ruby being grief-stricken over JFK’s death. It was an obvious hit.
There are some who speculate (with some pretty decent supporting circumstantial evidence) that JD Tippit was set up to be killed in order to frame Oswald, and that the Dallas PD would take care of Oswald to avenge their fellow cop. At the time of Oswald's arrest, the DPD were looking for him over the Tippit shooting and he was only later connected to JFK.
By this theory, Ruby was only cleaning up what others had hoped the DPD would take care of.