Is the date & time set correctly?
What version of macOS are you using? Older versions of Safari may be too outdated to connect to most websites as the Internet has changed drastically in the past couple of years. If you are using an older version of macOS you need to use a third party browser such as Google Chrome or Vivaldi. I believe Vivaldi only supports macOS 10.10+ so Google Chrome will likely be the same or require an even newer OS. If your Mac is capable of running a more recent version of macOS, then you can upgrade macOS which may give you more browser options.
If you provide the exact model of your Mac we can tell you what OS your Mac can use. You can get the exact model of your Mac by clicking on the Apple menu and selecting "About This Mac" or by entering your serial number here or here is the information is not show by macOS. Also tell us your current version of macOS.