The kings of the Hittites, Amorites, Canaanites, Perizites, Hivities and the Jebusites hear about the Israelites, and gather together to form a super cool kings club to fight Joshua.
When the citizens of Gibeon aren't invited to join the super cool kings club, they decide to trick the Israelites instead of fight them. They do this through the clever use of disguises and tomfoolery.
The Gibeonites, in 21st century fashion style, give all their clothing a "worn" look to fool the Israelites into thinking they are travelers from a far away land.
Maybe they hope the Israelites will go "Wow! Us too! This is so random!"
The Gibeonites are apparently Hivites according to 9:7. We know, this confuses us too. Don't feel bad, it also confuses scholars. Let this be a lesson on the importance of proofreading.
The Hivite/Gibeonite hybrid group explains to Joshua that they have heard of the God of Israel and wish to make treaty with the Israelites.
Deuteronomy 20:15 states that the Israelites must be more lenient with far away peoples than the ones they're conquering at the moment.
So Joshua accepts the treaty (i.e. moldy bread) and doesn't ask for God's wisdom on this matter.
Here's the thing, though. Skipping a quick chat with God is always a mistake for the Israelites. Pro tip: If you have access to an omnipotent being, take a moment to ask him what's what.
Three days pass and the Israelites discover the Gibeonites's ruse. The Gibeonites readily admit they're a bunch of liars because they know the Israelites have to honor the treaty they all made because it was sworn before the God of Israel. It pays to know the laws of your enemy, kids.
Joshua, being an honorable man, does not kill the Gibeonites, but rather has them become hewers of wood and drawers of water.
This may sound like a slave status, but Deuteronomy 20:16-18 explicitly erases the distinctions between classes, so don't worry.