Unless you have an employment contract with your employer, your employment is probably "at will," which means that your employer can fire you for any reason that isn't illegal. (Illegal reasons include discrimination based on race, sex, or another protected characteristic; retaliation for asserting your workplace rights; or punishing you for whistleblowing.) For more information on at-will employment, see Nolo's article Employment at Will: What Does It Mean?
Your employer's reason for firing you can be related to your job (for example, poor performance, excessive absences, or violating a company rule) or totally unrelated (for example, violating a law outside of work, speaking too loudly or abrasively, annoying your coworkers, or any other reason that is not illegal).
If you have an employment contract, however, the terms of your contract will determine the reasons for which you can be fired. Some contracts give a list of things for which the employee can be fired; others leave the issue open. In such a situation, the law usually says that you can only be fired for "good cause," which means a legitimate, business-related reason. If your contract says specifically that your employment is at will, however, you are stuck in the same boat as those without a contract, and your employer has a great deal of leeway when deciding whether to fire you.