Why aren’t these WordPress options being saved to the database correctly?

The options are not being saved correctly because you used the wrong input name — it should match the second parameter for register_setting(). So for example, with register_setting('myplugin_options_group', 'api_username'), the input name should be api_username, but then you used myplugin_api_username.

Additionally, it should be noted that screen_icon() has long been deprecated.