We know that Thor went all the way up to Nidavellir to get the Stormbreaker. But why on the earth did he not use Odin's spear? I mean, he could've scourged it from the debris of his spaceship and used it. From what I know, it’s the most powerful weapon in the whole universe.
Gungnir appears to have been left in the throne room in Asgard during Thor: Ragnarok when Ragnarok happens and Surtur destroys Asgard as I explain here. The last we see of it is when Hela disarms Thor.
It may be obvious to some but it's also worth noting that your familiarity with a specific weapon matters a lot and even more so when switching between types of weapons. Gungnir is a staff/spear with a ranged attack whereas Stormbreaker is a big old axe which is similar to a hammer somewhat. They require vastly different fighting techniques which Thor doesn’t seem to be able to use to well.
In the duel Thor has with Hela whilst wielding Gungnir, he is easily bested. In part, this is due to him not awakening his power and Hela being super strong but he was also unfamiliar with Gungnir, being mainly a hammer user until then. He didn't use Gungnir effectively because he was unfamiliar with it.
And of course this raises another important point, if he couldn’t beat Hela with it how would he beat Thanos with the Infinity Gauntlet and the Infinity Stones in it. Of course at this point he had awakened his true power so might have been more effective with Gungnir but we don’t know for sure because we don’t see him with the spear after that.
Asgard and everything on it was destroyed at the end of Thor: Ragnarok, I see no reason why this spear would have survived. If there was some reason for it to be around still then you still have to consider that it would have taken quite a while to find it amidst all of the space debris, there's a good chance they would have never found it. They were racing against time, or more specifically against Thanos, to get this weapon and stop him before he had all 6 Stones. If they had taken too long collecting it Thanos could achieve his goals before they had any chance to do anything about it.
So even if it were out there it would have been too much of a risk to take any significant amount of time looking for it.