In the prequels and Clone Wars, Yoda is a spry and agile 870 year old. In just a short amount of time in Yoda-years he becomes feeble and decrepit, then suddenly dies. What makes a Yoda suddenly (in Yoda-years) become sickly and weak?
Yoda is OLD. In his fights in the prequel trilogy, he draws heavily on the Force to sustain himself and enhance his speed, strength, etc.
This is seen quite obviously when he pauses to pick up his cane after the fight with Dooku, and mentioned in multiple Expanded Universe (since rebranded 'Legends') works (not always specific to Yoda).
On Dagobah, Yoda avoids using the Force as much as possible. He is there to hide his immense Force presence, masking it with the Dark Side presence of the cave. Thus, he doesn't extensively use his abilities - it could give him away. He is still relatively spry. Despite this, he is tired and worn out. Life in a swamp, especially if you've been used to the conveniences of a modern (or post-modern) world your whole life, is VERY difficult. Simple survival is a challenge.
By the third movie, he has become ill. He lives in a swamp, it happens. He is likely feverish, which affects his ability to concentrate, and his body is finally breaking down. He is also ready to go at that point - his final student has graduated, his tasks are all but complete, and there is essentially nothing left he can do to change what will happen.