Sounds like you have a loose or bad ground, follow your ground cable from the battery to where it attachs to the tractor, I think you will find your problem
Thanks everyone for your suggestions. I check the ground cable as someone suggested and it was loose and rusty. I am going to replace it see what happens. When I tightened it I could start with the key.