Development is for development.
Test is for testing.
Production is for...
They are switched on via ENV['RAILS_ENV']
Also switched on are the config/environments/* files.
You can have more environments if you choose.
Development and Testing are related in that when running tests, the development DB structure is moved into testing so that tests get run against the current development DB structure.
All of this structure is put in place to allow you to pre-define this information and not have to change code when it's used in different environments.