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 foot-ball?
Jim Hickey—St. Laurence, I suppose; he died on the “gridiron.” -- Puck (New York, NY) 5 Nov. 1890
The gridiron football field is an absolute monarchy. The captain of the eleven is the reigning czar, and the coaches are the power behind the throne. -- Boston Post, 29 Oct. 1893
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?