This a considered a conspiracy theory that is construed from luck benefitting America and modern understanding of historical events.
At that time most of the worlds navy's still believed in the dominance of the battleship and considered carriers to be secondary units whose true purpose was scouting and harassment. It was believed that the ability of an aircraft to damage or sink larger vessels was minimal and that only the big guns of heavy ships would be effective against other heavy ships. We now know this assessment was false, that the ability of aircraft to find enemy fleets at a distance, rendered the capital ships the secondary units and aircraft carriers the more important vessels.
America actually believed the threat of air attack against pearl harbor to be extremely limited. The distances involved, the belief that aircraft were generally ineffective, and the false understanding that torpedo attacks were not possible in pearl harbor due to its shallowness, meant that America believed the pacific fleet was safe in pearl harbor.
the Japanese attack on pearl harbor, intended to catch the entirety of the pacific fleet but their own attack plans placed a priority on battleships over carriers. the Japanese traveled under radio silence and did not receive any intelligence update until shortly before the attack commenced. The American carriers and some escorts had departed pearl harbor to deliver aircraft to another island and conduct exercises. The carriers were simply lucky not to have been there. The losses that were inflicted were not on old or outdated vessels. It was actually the attack on pearl harbor and the following pacific battles that would prove that the vessels that had been sunk were obsolete, not that America realized that at the time.
The idea that the attack was invited was propaganda that was spread by American isolationists to slander President Roosevelt because he had been a proponent of American interventionism. It was later taken up by other ideologies to push the "America is evil" agenda. The coincidence of the sparing of the American carriers is only suspicious in retrospect. If you would like to get a nice dramatized view of events, I would suggest the 1970 film "tora! tora! tora!", it presents the lead up events, the mistakes made, etc, from both the Japanese and American perspective.