Boston Marathon is the hardest race to get in, so much so that achieving BQ (Boston Qualifier) has become a lifetime goal for many runners.
For most people, the way to enter Boston Marathon is to run a qualifying time in a different marathon. It must be a "Boston Qualifying Marathon" which means that its official finish times are recognized by the BAA. You will often see those races proudly promote their status as a Boston qualifier, especially if they also have a flat/fast course that helps with BQ. Simply running a qualifying time for your age group doesn't guarantee your entry, however. You often have to be a few minutes faster in order to beat the cutoff, due to more people meeting the bar than spots available. Qualifying and cutoff times are announced by the BAA every year, which has turned into a big event in the runners' world.
Another way to get into Boston is to run for charities. You don't need to run a qualifying time, but you do need to raise a substantial amount of money.