Bundler is intelligent enough to only require gems for the current environment. The groups correspond to these environments. If your app is running in the development environment, Bundler requires the gems from that group, but not those from the test group, and so on.
People often put gems in the :development group that they need/want for their dev environment, but not on their production system.
The line
Bundler.require *Rails.groups(:assets => %w(development test))
simply says that Bundler will require the gems from the assets group only for your development and test environment. This stops your assets from being lazily compiled on your production server, where you usually want to deploy precompiled assets.