I understand that the Buddha became severely ill prior to his death as a result of eating bad food. I also was under the impression that perfectly enlightened beings have obliterated, or rendered ineffective, all of their karma. If this is the case, why would the Buddha, the most perfectly enlightened of all, experience great suffering at the end of his life?
"I also was under the impression that perfectly enlightened beings have obliterated, or rendered ineffective, all of their karma"
The five skhandas are roughly understood as "past kamma". Even arahants experience the fruits of their past kamma and are only free of it in parinibbana. For example, there are suttas describing arahants being hurt. In the case of the Buddha specifically, there's a well known one where he had his foot hurt:
I have heard that on one occasion the Blessed One was staying near Rajagaha at the Maddakucchi Deer Reserve. Now at that time his foot had been pierced by a stone sliver. Excruciating were the bodily feelings that developed within him — painful, fierce, sharp, wracking, repellent, disagreeable — but he endured them mindful, alert, & unperturbed. Having had his outer robe folded in four and laid out, he lay down on his right side in the lion's posture, with one foot placed on top of the other, mindful & alert.
-- SN 1.38
"If this is the case, why would the Buddha, the most perfectly enlightened of all, experience great suffering at the end of his life?"
It's generally understood that he suffered body pain (at least when not in jhana). His own teaching carries this (like the quote above):
"And what are the fermentations to be abandoned by tolerating? There is the case where a monk, reflecting appropriately, endures. He tolerates cold, heat, hunger, & thirst; the touch of flies, mosquitoes, wind, sun, & reptiles; ill-spoken, unwelcome words & bodily feelings that, when they arise, are painful, racking, sharp, piercing, disagreeable, displeasing, & menacing to life. The fermentations, vexation, or fever that would arise if he were not to tolerate these things do not arise for him when he tolerates them. These are called the fermentations to be abandoned by tolerating.
-- MN 2
A well known sutta on this subject is the The Arrow which illustrates the differences between pain and suffering. Thus, pain could be understood as simply bodily discomfort (even if sharp), but unable to do anything beyond that, say, to his mind (which is naturally not the case for any "normal" person). However, like in the foot episode, he does appear managing these discomforts:
Then the Blessed One — having spent most of the night instructing, urging, rousing, & encouraging the Kapilavatthu Sakyans with a Dhamma talk — said to Ven. Ananda, "Ananda, speak to the Kapilavatthu Sakyans about the person who follows the practice for one in training. My back aches. I will rest it."
-- MN 53
Finally, body pain (vedana in general) does not cease permanently with nibbana, if a body still has vitality.
The Buddha was still a human being in the sense that he had a physical body as a results of the 5 aggregates.
He was once asked if he was in pain regarding his pains in the back. His answer was that there was pain but he was not bothered by it.
As an enlightened being he had destroyed all defilements and fetters and would therefore not identify or take ownership of the pain. There would be noone to do that. There would just be pain - an impersonal phenomena.
Bear in mind that there's Suffering and suffering. "suffering" (lower-case "s") is the typical way in which the word is used. It is the workaday definition of "suffering", i.e., to be in discomfort, to not like something because it brings about physical or mental anguish: being hungry, in pain, heartbroken, in grief, etc. Believe it or not, these kinds of sufferings are rooted largely in our physiology, i.e., our nervous systems. We are wired to be repelled by pain, want to sate hunger, have mate(s), etc., because it is how we have evolved as beings, and for good reason. How long would any living thing live if it could simply ignore hunger or pain, or worse still, actually like it, esp. hunger? Such a species would quickly die out, and that is contrary to life itself. That we are alive shows our nature as living beings in this regard: we are alive because we do that which allows us to live, and that includes finding ways to sate hunger, address our wounds, find mate(s), etc. Living things that don't do that quickly die out.
"Suffering" (capital "S") is a different sort; it's "big-picture" kind of Suffering. All living things suffer (small "s"), and Buddha taught that and lived it (well, he had no choice). "Suffering" however is a choice. When a being chooses to accept as stimulation (or input) any sensation, feeling, or thought and simply acknowledge it without attaching to it (i.e., without identifying with it as being part of itself instead of it being a mere interpretation of stimuli), it is then that Suffering is avoided. There may still be suffering and that suffering is often a good thing to listen to: hungry? Get some food. Lonely? Get some company. In pain? Get some help. Lower-case "s" suffering thus is a very useful thing to have around. The mistake people make is that they over-identify with it sometimes and mistake it for being a permanent or definitive part of themselves, when in fact, it's transient input (whether generated by external force, as with pain from a medical condition, or internally, as when someone seems overly focused on pessimistic ideas). That is what Buddha taught: rising and falling, coming and going, it's all impermanent. Life itself is included in it; you were not alive before this life (well, leaving aside reincarnation ideas, at least not alive as you are today), then you are alive, then you'll die one day. So if you had never lived, it'd be all the same. You had to be born some time, so why kvetch about the fact that life is limited in duration? And if life has so much suffering in it, even for relatively well-off people such as those living middle-class or better lives in a first world country, why then would anyone really want to live forever? But our instincts naturally incline us to desire life, since that is a valuable (and evolutionarily advantageous) instinct to have. It impels us to defend ourselves against attack, get food, seek shelter, and weather all manner of hardships. So this desire to live is hardly useless. Yes, even Buddha had it. He just knew what place it held in the scheme of things and so didn't let it rule the very life that desire existed to protect.
When once asked what he was: a god, a diva, or something else, he replied no to all of them. He was then asked, well then, what are you? His reply was simple: "Awake". Well, for what that's worth, he was known for leaving people with answers that raised more questions than they answered.
But he never claimed (to the best of my knowledge) to be THE most supremely enlightened being to ever walk the face of the Earth, though a lot of other people have said that about him. Hard to say if they are right but if Buddha himself never claimed it, then I wonder what makes others think that about him? I'll say this about him: he got the whole all-is-impermanent thing down pretty good. And teaching loads of people how to meditate was a pretty nice thing to have done, too. So all in all, he was a pretty decent chap. Perfect? No. No one is. And perfect by whose standards, anyway? I think he'd be the first to tell you that perfection is relative, and it is.