Avengers: Infinity War finally shows the culmination of pretty much everything the Marvel Cinematic Universe has been building up to, mainly Thanos's quest to retrieve all of the Infinity Stones. While it may seem a little odd that Thanos would go after all of the stones at once, there is actually a fitting explanation. Warning: Major spoilers for Avengers: Infinity War lie ahead.
When we first see Thanos in Infinity War, he already has the Power Stone. The Power Stone is one of two Infinity Stones that are absolutely essential for Thanos's quest, with the other being the Space Stone. The Power Stone is important because, as its name suggests, it grants him seemingly unlimited power, making him practically unbeatable in a fight. The Space Stone is just as important as it can allow him to transport wherever he wants, which is an important part in traversing the galaxy to retrieve the six gems.
The reason Thanos waited for so long, considering that he is presumably hundreds of years old, is because up until around 2012, the Space Stone was hidden somewhere on Earth, and until 2014, the Power Stone was submerged deep within the oceans of Morag.
For ages, the Space Stone / Tesseract was buried in secret on Earth, until it was unburied by the Red Skull during the events of Captain America: The First Avenger. Even after that point, all information regarding the Tesseract was kept under wraps by S.H.I.E.L.D., until Loki found out about it at the end of Thor. Learning about this discovery, Thanos hired Loki to go to Earth to retrieve it, letting him borrow the Mind Stone during his quest. Though it was an Infinity Stone, the Mind Stone was expendable to Thanos, as it was not as important of a Stone and he could easily get it back once he had the Space and Power Stones (as he easily did at the ending of Infinity War).
The reason Thanos waited so long to retrieve the Power Stone was because it was literally submerged and protected on the planet Morag for centuries. However, as a deleted part of Guardians of the Galaxy explained, Morag, the planet from the beginning of the movie, will have its high tides drastically drop once every few hundred years. Eager to get his hands on the Power Stone, Thanos sent Ronan's men to retrieve the Stone for him. Had Star Lord not gotten in the way, Thanos would have had the Stone a lot sooner.
As the events of The Avengers and Guardians of the Galaxy revealed, neither of these plans worked out for Thanos. The Power Stone was held and protected on Xandar, which wouldn't be too big of an issue for Thanos, and the Space Stone was held and protected on Asgard, which would be an issue. While Thanos knew he could easily take out the Nova Corps and a bunch of Xandarians, taking on the people of Asgard, including Odin, would be too dangerous, so he waited.
During the events of Thor: Ragnarok, Odin passed away, which is when Thanos made his move. When we see Thor in Infinity War, he reveals that Thanos had destroyed Xandar and retrieved the Power Stone only a week before. Thanos was most likely waiting for the opportune moment, and the death of Odin and destruction of Asgard appeared to be just that, allowing him to retrieve every Infinity Stone in seemingly one perfect swoop.
As soon as Thanos had his hands on the Power Stone and Space Stone at the beginning of the movie, the universe was practically doomed. With unlimited power and the ability to go wherever he would want, Thanos was virtually unstoppable. No Avenger could fight off his strength, and not even the force field around Wakanda could keep him away from the Mind Stone.
While movies like Justice League keep us scratching our heads, making us wonder why the hundreds-of-years-old villain would choose that moment to attack the Earth, Infinity War's timeline (at least regarding the Infinity Stones) is pretty spot on. Marvel Studios have truly given us a well thought out movie that audiences and critics alike all seem to enjoy.