When you throw something, gravity tries to bring it down to the ground as soon as possible and air resistance pushes against it.
If you throw a ball straight up, all of your force is used up making the object go up and none sideways. If you throw it sideways, gravity soon brings it down.
You have to throw up at an angle close to 45 degrees to get it to go as far as possible.