You can get your salesforce Org ID and other info from Company Information in the Setup menu. But, if you need to get the data from SOQL, here is the sample query
SELECT Id, Name, InstanceName, DefaultLocaleSidKey, TimeZoneSidKey FROM Organization
While for Sandbox info, you can go to the Sandboxes in the setup menu in Prod. The same, you can use SOQL to get the information, but you need to use Tooling API.
SELECT Id, SandboxName, Description, LicenseType, HistoryDays FROM SandboxInfo
The Id returned here is SandboxInfo ID, not the Org ID and unfortunately, we can't get the Org ID.
You will get the same result if perform query with Rest Explorer from Workbench