That depends on which legendary. The original bird trio randomly
shows up in the lab, but you have to have luck to find one. A way
to get some legendaries is in the berry garden at level 30. You can
get legendaries in the tall grass with the legendary radar chip and
the appropriate inventory item (like enigma stones). The Royal
Tunnel gives out legendaries if you can finish the levels. The
ancient cave has quests for legendary Pokemon, but all except for
the Harvest Sprites require finding an item first. The gem
collector has a couple of legendaries. The game center prize
exchange has legendaries. Emera Square has one legendary. Finding
rumbling maps and using them will get you some summon items for
legendaries. There's a legendary on Route 53, and a couple at the
Safari Zone (though you need the right items for the Safari Zone).
Completing your regional Pokedexs can also get you legendaries. It
is more or less scattered all over the site, and it requires to do
a variety of different things if you want all the legendaries. Of
course, you can always buy them off of other players who are
selling them, but that would be quite expensive.