Gridiron has been used colloquially to refer to the American football field since 1890, when the game we know as American football (or gridiron football) started growing in popularity. Our first recorded use of the "football field" meaning gives us a hint as to where gridiron came from:
Tom Stokes—Who was the first man killed at football?
Jim Hickey—St. Laurence, I suppose; he died on the “gridiron.” -- Puck. (The Critic, 18 Nov. 1890)
The truth is, gridiron is much older that football. When the word first came into English in the 1200s, it referred to a grill grate used for torture. The St. Laurence mentioned in the 1890 joke was purportedly martyred by being grilled to death, even quipping to his captors, "I am cooked on that side; turn me over, and eat."
It wasn't the torturous play that made football players and fans think of the method of St. Laurence's demise, but the field itself. Early football fields were marked in a grid, not by the familiar parallel yard lines we know today, and the association between a grid and the word gridiron was too strong to shake. Gridiron had already been applied to other things that resembled a grill grate, so why not the football field?