There are several origis according to The Mavens Word of the Day, including this one areferencing the OED:
The OED gives a 1574 quote for spill it meaning 'to divulge, let out': "Although it be a shame to spill it, I will not leaue ['omit'] to say that which..his friends haue said vnto me." This collocation appears to have died out after that until it came into use in the U.S. in the early 20th century: "'Go ahead and spill it,' I says" (Ring Lardner, Gullible's Travels, 1917). Our related phrase, spill the beans, is first attested in 1919: "'Mother certainly has spilled the beans!' thought Stafford in vast amusement" (T. K. Holmes, Man from Tall Timber).