There is apparently 2 types of latches for the rear hatch. One for power lift and one for manual lift. I have a manual lift and the latch has 3 contacts in the connector. I was able to shake the hatch when it was closed, and get the warning to flash on and off. After removing the latch assy, I separated the plastic actuator part from the steel latch and found grease only on the plastic pin that moves the copper strap when the latch goes to the full closed position. this grease is necessary to reduce wear on the plastic pin. The ohmeter showed the switch working ok, so I reassembled the latch and reinstalled it.
With the hatch open, I used a phillips screwdriver shank to simulate the striker and moved the latch to the full closed position. No amount of jiggling would cause the warning to come on. The problem was the latch was never going to the fully closed position. Toyota made no provision for latch or striker adjustment, so I removed the three latch mounting bolts and slotted the holes with a round file, about .030" so I could move the latch closer to the striker. That did the trick and it works fine now. I suspect the reason that it latched ok for 4 years, and then started to act up, is caused by the rubber bumpers on the bottom corners of the hatch getting less pliable as they age.
Thanks to the comments on this thread, I decided to check it out before giving the dealer over 500 bucks to replace a perfectly good latch.
Update: The Real Fix.. 500 miles later the problem came back during left turns. I isolated the problem to the latch by disconnecting the connector and driving around. I again removed the latch and separated the plastic actuator from the steel latch assembly. When looking inside the latch you can see the copper strap that is the switch. At the back end, the strap lays against a copper pin when the latch is open. As you close the latch you will see the plastic pin move the copper strap (looking thru the front end) and looking thru the back end you will see the end of the copper strap move away from the copper pin when the latch is fully closed and locked. At this point there should be at least .030" ( about 3 credit cards thick) clearance between the strap and the pin. Mine had about .005 (the thickness of 2 sheets of paper). Unlock the latch by moving the little silver lever. With the latch unlocked I slid a small hooked awl in the back end between the strap and the latch wall. by twisting the awl I bent the middle of the strap toward the plastic pin slightly. Now when the latch was closed the end of the copper strap moved away from the copper pin about .030". I reassembled everything and went out for a test. No more problems.