Just circumstance. He happened to be in the right place at the right time.
Oswald wanted to kill 'someone important' to make a name for himself. He tried and damn near succeeded in killing General Walker a few month before. When Kennedy decide on his own that morning not to use the bullet proof bubble top for the limo, his fate was sealed.
Everyone who knew Oswald closely (and there weren't that many) were convinced that he did it on his own. That includes both his wife and his brother.
The bubble-top for the limousine wasn’t bulletproof. It was weatherproof only. I was only used in inclement weather.