What is the purpose of storing `siteurl` in database?

Since you mention multiple environments you can manually define the site URL within your wp-config.php file

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wordpress');

Keep in mind that it will override what you have set in your options table. As detailed in the documentation:

Setting this value in wp-config.php overrides the wp_options table value for siteurl and overrides the WordPress address (URL) field in the Administration > Settings > General panel when logging in using wp-login.php. It will not update your Home url.