France had plans for potential action and annexation of Egypt for some time, with individuals such as the aristocrat and military's officer François Baron de Tott in 1777 expressing the idea after travel to the Levant. Napoleon himself had expressed some ideas of going to Egypt during his First Italian campaign in 1796 in discussions with the Foreign Affairs minister Talleyrand. Following his victory in Italy, Napoleon petitioned the French government, now under The Directory, to invade Egypt. This was done for multiple reasons. Initially Napoleon wanted to invade Great Britain but France lacked the naval capacity to do so. Egypt was chosen as an alternative. An invasion of Egypt would weaken Britain's connection to its colonies in India, which was crucial as they were dealing with the Mysore wars against Tipu Sultan. It would attack British interest and commerce while expanding France's own. Plan where also made to create large amounts of farming to supply France with food from Egypt. Ideas of a proto Suez Canal were also discussed but premature.
The invasion itself was staged in the city of Toulon (the place where Napoleon first gained some notoriety as a military leader). A fleet of 13 ships of the line, 14 frigates, and hundreds of transport ships was assembled, with around 40,000 troops gathered in French ports on the Mediterranean. Massing of men on this scale caused rumors to circulate, gaining the attention of the British. However, the target of the French invasion was kept secret to Napoleon and a very few in his inner circle such as General Berthier. The ships launched on the 19th of May well supplied but not overly burdened as room was needed for military equipment, men, and potential loot. Much like his campaign in Italy, Napoleon was going to make war pay for war and loot Egypt to make up for a large amount of his supplies. New technology such as new ovens for bread that were lighter to carry did allow them to be more mobile while keeping the ability to make bread.
On his way to Egypt Napoleon, Napoleon landed on the island of Malta on the 10th of June, 1798. The island was under the control of The Order of St. John, which was Catholic military order from the medieval era. Within two days, the Order capitulated to Napoleon after little real resistance. Napoleon raided the treasury and send the loot back to the debt-burdened Directory. In addition, Napoleon raided the military cache of the order, securing around 40,000 muskets, over 1000 artillery pieces, a couples ships (mostly galleys and frigates), and over a million pounds of gunpowder. Napoleon stayed in Malta for a couple days, reorganizing the government to be more in line with French revolutionary ideas, and set the island up as a station for resupplying Egypt from France.
Napoleon's supplies from France did not last long as the British fleet under Admiral Horatio Nelson, who had been trying to follow Napoleon's fleet, got word from a dispatch in Egypt of Napoleon's arrival at Alexandria on 1st July 1798. Malta was blockaded and would remain that way for two years, and the British would destroy most of the French fleet in the Battle of Abu Qir Bay on the first couple days of August in 1798. The British fleet cut Napoleon's link to France, meaning he was relegated to only what he could loot from Egypt and the Levant to supply his army. Facing defeat after his failed attempt to capture Acre in 1799 meant Napoleon was force to retreat as supplies were thin and his army was suffering from the bubonic plague. While initially able to resupply from France, the British quickly severed his line of communication and relegated him to whatever could be sourced in Egypt and the supplies they initially departed with.