get_option() returning empty

I can’t see where the $option_name is declared, and don’t know what it contains.
You are using that variable ($option_name) in the name attribute of the checkbox.

You need to give to the name attribute of that checkbox field the name of your option. That is the second argument in the register_setting function. So if $option_name is not declared, you should give it the value “theme_settings”.

You also need to set the value attribute of the checkbox.

After that you can use something like this in your checkbox:

<input type="checkbox" id="<?php echo $id; ?>" name="<?php echo $option_name; ?>[<?php echo $id; ?>]" value="some-value" <?php echo $option_name[$id] == "some-value" ? 'checked' : ''; ?> />

I believe that there is some code missing and it is possible that there might be some inconsistencies in settings_fields or do_settings_sections.