How can a spaceship travel through space if there is space debris flying around at very high speeds?
Wouldn't even a small rock crack through the spaceship?
Yes, that is entirely true. All this "junk" is usually separated in two categories: space debris (man-made), and micro-meteoroids (natural origins).
Micro-meteoroids are not as common as you might think. Even when you fly straight through the asteroid belt, micrometeorite impacts will be extremely unlikely. This is because small objects (dust, comet debris, ...) get pushed out of the Solar system by solar radiation pressure, are very likely to fall on a nearby asteroid, be caught in some planet's gravity field (Jupiter, mostly), etc. In short, small celestial bodies (in the order of cm or less) generally have a very short life span on astronomical time scales.
They can however be a problem near Jupiter for instance, which, because of its large mass, is a gravitational sink for these small objects. Even though they won't live there for very long, there are just so many of them flowing into Jupiter's gravity well all the time that they might just pose a problem. They haven't caused any major problems in exploration missions yet, but nevertheless, the Galileo spacecraft and most others flying to or past Jupiter were equipped with micro-meteoroid impact protection systems around the most critical components.
Space debris is a very active field of study. As it is man-made, it is only a problem of any size for spacecraft near the Earth. The importance of most near-Earth satellites and the threat space debris poses to them is why NORAD keeps track of most space debris in the vicinity of Earth. Information gathered by NORAD is used by space mission designers, so that they can design a spacecraft's trajectory such that it avoids collisions with larger (>~10cm) chunks of space debris.
Although this prevents most catastrophic collisions, it is very difficult if not impossible to track all the smaller objects (<~10cm). There are unfortunately many millions of such things close to the Eartch, which sometimes indeed leads to impact. Solar panels from the ISS returned to Earth are riddled with holes, dents, scratches, etc., all resulting from impacts with space debris. The ISS has a lot of shields all over able to withstand impact with objects smaller than a few mm. For instance, the windows of the ISS are not simply a few layers of glass; there's pressure panes, primary shield, secondary shield, scratch panes, etc. Teh overall thickness of a window can exceed 40cm. The shield in front of a window is designed to be strong enough to break any impacting particle up into lower-mass dust, which then sprays out over the deliberate spacing between the primary shield and auxiliary pressure pane, the latter of which is then able to withstand the lower energy impact of the dust. It's kind of like bullet-proof glass, but then for bullets travelling several km/s :)
Space debris is not really a problem yet, because even though there is a large number of objects orbiting the Earth, the volume they fly through is so vast that the average density is still very low. But, when things like this happen, there is a major impact on many space missions, existing and future ones. When not taken seriously between now and ~15 years, space debris might indeed become a real threat, possibly even leading to the Kessler syndrome.
That's right. Any significant space debris hit can do heavy damage to spaceship because we don't have shield technology like sci-fi world.
Well, we set spaceship trajectories so that we never encounter space debris in the way (unless intended like once NASA hit a probe to asteroid to study it).