The accepted answer is half the answer. As marcvangend notes, there are two options in Drupal 8 for what used to be stored in the variables table and was stored and retrieved with
variable_get(). The first, documented in darol100's answer, is the State API.
The second is the Configuration API and should be used in most cases where you have a configuration form. It requires at minimum in your module a configuration installation file, for example
config/install/example.settings.yml. For a single piece of configuration (with multiple potential values), that file could just contain for example:
And then use the value with:
$types = \Drupal::config('example.settings')->get('test_content_types');
Or change the stored values with:
->set('test_content_types', ['article', 'page'])
See also the the Drupal 8 documentation for D7 to D8 configuration upgrades and using configuration in modules.