Ultra Beasts are a collection of Legendary Pokemon that are classified as such due to the fact that they come from an alternate dimension. During the Main Storyline, you will encounter a few Ultra Beast; however, you will won't be able to obtain any of them until after defeating Ultra Necrozma. You will battle the Ultra Recon Squad with their Ultra Beast, Poipole, on a number of occasions, as well as a wild Nihilego the first time you visit Aether Paradise.
As the story unfolds, Lusamine and the Aether Foundation will selfishly look to use Cosmog (who is actually an Ultra Beast in its own right) to create an Ultra Wormhole in hopes of defeating Necrozma on their own to prevent it from stealing the light of Alola. After capturing Cosmog from Lillie, Lusamine will attempt to do that exact thing by opening an Ultra Wormhole. However, by doing so, more Ultra Wormholes will appear across The Alola Region, forcing the Kahunas of each island to deal with them.
After defeating Ultra Necrozma, you will earn access to traveling into and through Ultra Space. Ultra Space has a number of Wormholes found within it, ones that can sometimes lead to the majority of the Ultra Beasts. Since they are found in Ultra Space, these given Ultra Beasts will start with a stat boost due to the energy from the Ultra Wormhole. Ultra Beasts found through Ultra Wormholes have no limits on how many times they can be found. All Ultra Beasts can now be found in their Shiny Forms.