Odin Borson was the son of Bor and the father of Thor and Hella, also referred to as the All-Father because he ordered peace in all the 9 realms including Midgard aka earth. There have been multiple speculations as to why Thanos never attacked Asgard and claimed the infinity stones and the infinity gauntlet that was already there in the vault at Asgard along with the space stone in the form of the tesseract. Odin Borson was revered for a reason and the reason is very simple, he was the strongest Asgardian after his father Bor passed away. During his numerous escapades across the galaxy, he gained the reputation of All-father maybe because he would never resort to killing women and children and had his army do the same. Odin was also feared for his power and his power using the Odin force had a lasting effect on peace across all the realms once he has announced it.
Odin’s power supersedes any of the existing data that anyone might have on him, apart from stories and a reference by Thor in Thor: Ragnarök where Thor is transported to an astral realm where he can still seek advice from Odin. Thor claims that he may never be as strong as his father. Which outlines the kind of respect Odin had commanded with his past deeds. In the Marvel Cinematic Universe, we do not have many references to his power, strength, or durability, but we have multiple references to his feats of strength. By birth Odin was an Asgardian, but not the typical one at that. He was the son of the, then Asgardian king who wielded the Bor force and while being born of the King in command of the force was able to summon some at the time of his birth making him stand apart from the class of even the most elite Asgardians of Asgard.
Then came the time when he by himself defeated Surtur, a supernatural being with immense power and the rage of the eternal fire burning within Surtur. Odin managed to separate both and put a stop to Ragnarök. The next reference of his feat of strength comes from the fact that he was the one who put a stop to Hela, his eldest offspring who had gone on a rampage when her father took on peace to solve the matters of the realm and she decided to revolt and take Odin’s power by force. Odin was able to lock her away by using his force as a lock, sealing her away to hell for a long time.
The extent of Odin’s power can be gauged from the scene in Thor: Ragnarök, where someone like Hela, who could not have been stopped by Thor, Valkyrie, and Hulk put together, was unable to go against Surtur. Hela was the only Asgardian who was able to draw her power from Asgard and at that time they were on Asgard. But Odin was not only able to overpower both Surtur and Hela, but also managed to seal them away with his magic for a long time.
The real reason why Thanos never attacked Asgard, is because he did not know the precise location of the Soul Stone. Yes, he never knew about the soul stone until he tortured Nebula in front of Gamora to extract the information he needed. In the earlier stories, he was aware of the locations of the stones except for the soul stone and also needed a gauntlet to help him wield the power of the infinity stones. The only people who were capable of crafting the mystical gauntlet that Thanos needed. But the recent events that unfolded, left the dwarf clan without the protection of Asgard as Odin had moved on to the Afterlife and was attacked by Thanos and his army as there was no one to protect them. With Odin out of the picture and armed with the location of the Soul Stone, Thanos could finally put his plans in motion and gather the stones without any hindrance.
Even if in the presence of Odin, if Thanos would have attempted to go for the stones, he would have met a lot of resistance especially from Odin and for the gauntlet if he would have raided the planet of the dwarfs to make for him a gauntlet, he would have again would have had to face Odin as the dwarves were under Asgard’s protection and Odin was the king of Asgard and the protector of the 9 realms.