I’ve always thought it was Ruby protecting his family from threatened death if he didn’t take the fall. Either way, he was coerced.
Ruby knew he was going to die of cancer.
His mob bosses made a deal with him:
If he shot Oswald—they would take care of his family after he was gone.