Whilst the first apple pie recipe is credited to Chaucer back in 1381, that was a pie containing multiple fruits; and, therefore, not strictly apple pie. It might have been the first recorded recipe of a pie containing apples.
Since it is believed that the apple tree was first introduced to the colonies by English settlers, apple pie could not have existed in the USA before the USA was first founded in 1776/1781.
To lay claim to having been the origin of the apple pie, a country must have access to apples (presumably, therefore, apple trees must grow) and be familiar with the cookery principles required to make a pie from them. Given that the apple tree originated in what is the Middle East and Eurasia, a pie most likely originated there.
Perhaps the question should be reworded to “where did American Pie originate?” That was USA 1971, Don McLean.