The exodus would have been impossible if Joseph's bones had remained behind. Therefore Moses made it his concern to seek their resting-place, while the people had but the one thought of gathering in the treasures of the Egyptians.  But it was not an easy matter to find Joseph's body. Moses knew that he had been interred in the mausoleum of the Egyptian kings, but there were so many other bodies there that it was impossible to identify it. Moses' mother Jochebed came to his aid. She led him to the very spot where Joseph's bones lay. As soon as he came near them, he knew them to be what he was seeking, by the fragrance they exhaled and spread around.  But his difficulties were not at an end. The question arose, how he was to secure possession of the remains. Joseph's coffin had been sunk far down into the ground, and he knew not how to raise it from the depths. Standing at the edge of the grave, he spoke these words. "Joseph, the time hath come whereof thou didst say, 'God will surely visit you, and ye shall carry up my bones from hence.'" No sooner had this reminder dropped from his lips than the coffin stirred and rose to the surface.
And even yet the difficulties in Moses' way were not removed wholly. The Egyptian magicians had stationed two golden dogs at Joseph's coffin, to keep watch,. and they barked vehemently if anyone ventured close to it. The noise they made was so loud it could be heard throughout the land, from end to end, a distance equal to a forty day's journey. When Moses came near the coffin, the dogs emitted their warning sound, but he silenced them at once with words, "Come, ye people, and behold the miracle! The real, live dogs did not bark, and these counterfeit dogs produced by magic attempt it!"  What he said about real, live dogs and their refraining from barking had reference to the fact that the dogs of the Egyptians did not move their tongues against any of the children of Israel, through they had barked all the time the people were engaged in burying the bodies of their smitten first-born. As a reward God gave the Israelites the law, to cast to the dogs the flesh they themselves are forbidden to eat, for the Lord withholds due recompense from none of His creatures.  Indeed, the dogs received a double reward, for their excrements are used in tanning the hides from which the Torah scrolls are made, as well as the Mezuzot and the phylacteries. 
Joseph's coffin in the possession of Moses, the march of the Israelites could begin. The Egyptians put no manner of obstacle in their way. Pharaoh himself accompanied them, to make sure that they were actually leaving the land,  and now he was so angry at his counselors for having advised against letting the Israelites depart that he slew them. 
For several reasons God did not permit the Israelites to travel along the straight route to the promised land. He desired them to go to Sinai first and take the law upon themselves there, and, besides, the time divinely appointed for the occupation of the land by the Gentiles had not yet elapsed. Over and above all this, the long sojourn in the wilderness was fraught with profit for the Israelites, spiritually and materially. If they had reached Palestine directly after leaving Egypt, they would have devoted themselves entirely each to the cultivation of his allotted parcel of ground, and no time would have been left for the study of the Torah. In the wilderness they were relieved of the necessity of providing for their daily wants, and they would give all their efforts to acquiring the law. On the whole, it would not have been advantageous to process at once to the Holy Land and take possession thereof, for when the Canaanites heard that the Israelites were making for Palestine, they burnt the crops, felled the trees, destroyed the buildings, and choked the water springs, all in order to render the land uninhabitable. Hereupon God spake, and said: "I did not promise their fathers to give a devastated land unto their see, but a land full of all good things. I will lead them about in the wilderness for forty years, and meanwhile the Canaanites will have time to repair the damage they have done."  Moreover, the many miracles preformed for the Israelites during the journey through the wilderness had made their terror to fall upon the other nations, and their hearts melted, and there remained no more spirit in any man. They did not venture to attack the Israelites, and the conquest of the land was all the easier. 
Nor does this exhaust the list of reasons for preferring the longer route through the desert. Abraham had sworn a solemn oath to live at peace with the Philistines during a certain period, and the end of the term had not yet arrived. Besides, there was the fear that the sight of the land of the Philistines would awaken sad recollections in the Israelites, and drive them back into Egypt speedily, for once upon a time it had been the scene of a bitter disappointment to them. they had spent one hundred and eighty years in Egypt, in peace and prosperity, not in the least molested by the people. Suddenly Ganon came, a descendant of Joseph, of the tribe of Ephraim, and he spake, "The Lord hat appeared unto me, and He bade me lead you forth out of Egypt." The Ephraimites were the only ones to heed his words. Proud of their royal lineage as direct descendants of Joseph, and confident to their valor in war, for they were great heroes, they left the land and betook themselves to Palestine.  They Carried only weapons and gold and silver. They had taken no provisions, because they expected to buy food and drink on the way or capture them by force if the owners would not part with them for money.
After a day's march they found themselves in the neighborhood of Gath, at the place where the shepherds employed by the residents of the city gathered with the flocks. the Ephraimites asked them to sell them some sheep, which they expected to slaughter in order to satisfy their hunger with them, but the shepherds refused to have business dealings with them, saying, "Are the sheep ours, or does the cattle belong to us, that we could part with them for money?" Seeing that they could not gain their point by kindness, the Ephraimites used force. The outcries of the shepherds brought the people of Gath to their aid. A violent encounter, lasting a whole day, took place between the Israelites and the Philistines. The people of Gath realized that alone they would not be able to offer successful resistance to the Ephraimites, and they summoned the people of the other Philistine cities to join them. The following day an army of forty thousand stood ready to oppose the Ephraimites. Reduced in strength, as they were, by their three days' fast, they were exterminated root and branch. Only ten of them escaped with their bare life, and returned to Egypt, to bring Ephraim word of the disaster that had overtaken his posterity, and he mourned many days.
This abortive attempt of the Ephraimites to leave Egypt was the first occasion for oppressing Israel. Thereafter the Egyptians exercised force and vigilance to keep them in their land. As for the disaster of the Ephraimites, it was well-merited punishment, because they had paid no heed to the wish of the father Joseph, who had adjured his descendants solemnly on his deathbed not to think of quitting the land until the redeemer should appear. Their death was followed by disgrace, for their bodies lay unburied for many years on the battlefield near Gath, and the purpose of God in directing the Israelites to choose the longer route from Egypt to Canaan, was to spare them the sight of those dishonored corpses. Their courage might have deserted them, and out of apprehension of sharing the fate of their brethren they might have hastened back to the land of slavery.