Joseph's brothers had planned on killing him but Reuben, Joseph's oldest brother overheard and told them that they did not want blood on their hands and told them to throw him in the well instead with plans to come back and get him later.
The brothers saw there would be no profit from just throwing Joseph in the well so they sold him to Ishmaelites who were travelling by camel to Egypt. The Brothers had also taken Joseph's coat and slaughtered a goat and covered the coat in blood to show their father so he would think that Joseph had indeed been killed by a mountain lion.
In Egypt Joseph was sold to Potiphar who was Captain of the guard.
After a while of Joseph working for Potiphar, Potiphar's wife tried to seduce Joseph but Joseph refused saying that she was his master's wife so he runs away.
Potiphar's wife had thrown a knife at Joseph which had caught a piece of his clothing and so Potiphar's Wife called the guards claiming that Joseph had tried to attack her, which got Joseph sent to jail.