The Phrase Finder (
https://www.phrases.org.uk/meanings/218800.html) says:
The link between buckets and death was made by at least 1785, when the phrase was defined in Grose’s
Dictionary of the Vulgar Tongue:
"To kick the bucket, to die."
One theory as to why, albeit with little evidence to support it, is that the phrase originates from the notion that people hanged themselves by standing on a bucket with a noose around their neck and then kicking the bucket away. There are no citations that relate the phrase to suicide and, in any case, why a bucket? Whenever I've needed something to stand on I can't recall ever opting for a bucket. This theory doesn't stand up any better than the supposed buckets did.
The mist begins to clear with the fact that in 16th century England
bucket had an additional meaning (and in some parts it still has), i.e.
a beam or yoke used to hang or carry items. The term may have been introduced into English from the French
trébuchet - meaning a
balance, or
buque - meaning a
yoke. That meaning of bucket was referred to in Peter Levins'
Manipulus vocabulorum. A dictionarie of English and Latine wordes, 1570:
"A Bucket, beame, tollo."
and was used by Shakespeare in
Henry IV Part II, 1597:
"Swifter then he that gibbets on the Brewers Bucket." [to gibbet meant to hang]
The wooden frame that was used to hang animals up by their feet for slaughter was called a bucket. Not unnaturally they were likely to struggle or to spasm after death and hence 'kick the bucket'.