The ritual dismantling of the shrines every 20 years (known as sengu-shiki) goes back to prehistoric times, when sacred structures tended to be erected for special ceremonies rather than as permanent places of worship.
Rebuilding the shrines is an extremely efficient process, with most shrines only take three or four days to entirely rebuild.