Fairgrounds and funfairs are connected. Fairgrounds began in Greek times, were copied by Romans, then forgotten until Anglo Saxon times. They grew again in medieval times when people used to go to annual or seasonal fairs in order to buy goods. Entertainments were usually put on at the same event, and this was as close as most people came to a holiday.
Most fairs in medieval times were held close to religious holidays, so that people could easily remember when the fair was.
So the main purpose of the fairground was to provide a large space for buying and selling goods. The entertainments were on the side.
Eventually this changed so that the whole purpose of the fair was to entertain. So the whole fairground became filled with entertainments. It became a funfair.