Spice is used by navigators
to find safe passage between the stars. So, how does that work?
shareWell, basically, they are [formerly] humans that were enhanced by Spice to be able to do complex mathematical equations, and their brains are advanced enough to take two sections of space, fold them together on a quantum level, and teleport themselves, the ships they're in, and the people they are transporting along with them to the new location.
It's kinda weird, but the original "Dune" novel never explicitly explained the crossing when Paul's family traveled to Arakkis from Caladan, but the 1984 movie and the 2000 miniseries illustrated it very clearly.
The problem was, centuries before the story happened, humans had Artificially Intelligent machines helping them navigate starships to travel through space. The AI's eventually rebelled, causing what was called, the "Butlerian Jihad," or the Machine Wars. Humans did win those wars, but only by a close margin. After that, building intelligent machines was outlawed, because they couldn't be trusted. So where did that leave the humans when it came to space travel? They realized one way their society could advance was to change themselves, and the discovery of Spice on Arakkis changed everything.
Spice, when ingested or inhaled in a medical setting, has an interesting effect on humans. In a refined, purified form, it can enhance the human brain and awaken dormant abilities the person wouldn't otherwise have access to. It also extends the human lifespan. Near-constant, heavy exposure to it can transform a human completely into something completely unrecognizable.
The quest to enhance humans led to several factions and "schools" arising, and for the sake of this post, we'll focus on the Navigators. People who join the Navigator's Guild have to be committed for life, because once you get started, there's no going back. They are trained already from childhood in how to be a Mentat, a person whose brain is enhanced by Spice while studying and memorizing complex math. Mentats basically a "human computers," they take the place of machine calculations. When they join the Navigator's Guild, they are taught to memorize 3-D maps of the entire galaxy, which is a very long, arduous process, but not as long as the medical treatments.
Treatments are done on the new recruits over a period of years, exposing them to "spice gas," as it's called, which continues to enhance their minds, but it also transforms the person's body over time, until there's a point where they have taken on an alien-like appearance and can no longer survive outside of the artificial environment of spice gas. But when the final enhancement is made, they become super-beings that can "fold space," traveling from one location to another with very little movement. It's because of this that they have a monopoly on long-distance space travel during Paul's time in the story. Incidentally, long-distance space travel is expensive, due to the amount of Spice needed for the Navigators to do their job.