609. – Then (v. 22) he continues with the example of Joseph's faith and mentions two things which are stated in the last chapter of Genesis, where he said to his brothers (v. 24): 'God will visit you,' and commanded them to carry his bones out of that place. Hence, his faith bore on two things: first, because he believed that the promise He made would be fulfilled by the return of the children of Israel to the promised land; secondly, because he believed that Christ would be born and would rise from the dead in it, and many with him. Hence, he desired to have a part in that resurrection. He sa...ys, therefore, By faith Joseph, at the end of his life, made mention of the exodus of the Israelites; and this in regard to the first: and gave commandment regarding his bones, as to the second.
610. – But why did he not cause himself to be carried at once like his father. I answer that he was not able, because he did not then have the power he had at his father's death. Secondly, because he knew that the children of Israel were to suffer many afflictions after his death. Therefore, to assure them of their deliverance and return to the promised land, he willed his body to remain with them as a consolation. Hence, Moses took it with him, just as each tribe took the body of its father, as Jerome says.
Source: Commentary on Hebrews