Export set variables from site to include in install profile
A year or so ago I was working on a Drush command to export a working site as an installation profile. I haven't worked on it for a while, but it was my intention to use something like the Configuration Management module, or perhaps Drush CTools Export Bonus to include site configuration information with the installation profile.

If you are hand-generating your installation profile, typically you do write variable_set commands and put them directly into your installation profile.  When generating configuration information, though, I think it is typically the case that the config information is bundled in some other module.

Answering first question

By convention, variables in the variables table are  named after the module that defined them, so if everyone is cooperating, you know where the variables are coming from.  Install a fresh copy of Drupal, and make note of the variables that it defines, and their default values.  Compare these against the values in your site to find the ones you have changed.  Do the same thing for contrib modules, installing each module in your scratch site, and checking the default values.  Another option is to use Strongarm, which will show you the variables that changed (when they change), just like other features modules do.

The catch here, though, is that not all configuration is stored in the variables table.  Some modules define their own tables.  If you want to hand-code your configuration, you need to investigate the APIs for each module you use in turn, and figure out how to make settings programatically.  This is a difficult thing to do, which is why most people use features, or the configuration management module, or Ctools export bonus.  Even these modules are not always enough, as not everything supports exportables. It's a good thing that the CM initiative in D8 is addressing this problem.